如何修复我的BigQuery日期转换问题?

huangapple go评论55阅读模式
英文:

How can I fix my conversor date Problem on BIG QUERY?

问题

select CONCAT( SUBSTR(date, 0 , 4), '-', SUBSTR(date, 5 , 2), '-', SUBSTR(date, 7 , 2),' ', CAST( H.hour as string format '00'), ':',CAST( H.minute as string format '00'), ':00' )

英文:

I'm trying to convert a YYYYMMDD and hour minute to DateTime on Big Query (each one comes separetly)
The code is:

`select  CONCAT( SUBSTR(date, 0 , 4), '-' ,SUBSTR(date, 5 , 2), '-' , SUBSTR(date, 7 , 2),' ', CAST( H.hour as string format '00'),':',CAST( H.minute as string format '00'),':','00' )`

enter image description here

How can I delete that space?
I can't see the problem and I need to Convert that to DateTime

BY now, I try to convert that data to datetime by a few ways BUT I couln't solve it yet.

答案1

得分: 0

在Bigquery中,可以按照以下步骤执行此操作:

  1. 使用parses_date()函数获取日期对象。
  2. 将小时和分钟添加为time对象。
  3. 构建datetime对象
datetime(parse_date('%Y%M%d', date), time(H.hour, H.minute, 0))
英文:

In Bigquery, this can be done by the follow steps

  1. Use parses_date() function to get date ojbect
  2. Add hour and minute as time object
  3. Construct the datetime object
datetime(parse_date('%Y%M%d',date), time(H.hour, H.minute,0)) 

huangapple
  • 本文由 发表于 2023年3月15日 17:47:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/75742979.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定