英文:
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' )`
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中,可以按照以下步骤执行此操作:
- 使用parses_date()函数获取日期对象。
- 将小时和分钟添加为time对象。
- 构建datetime对象
datetime(parse_date('%Y%M%d', date), time(H.hour, H.minute, 0))
英文:
In Bigquery, this can be done by the follow steps
- Use parses_date() function to get date ojbect
- Add hour and minute as time object
- Construct the datetime object
datetime(parse_date('%Y%M%d',date), time(H.hour, H.minute,0))
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论