Skip to content
Advertisement

String to Datetime in BigQuery

How do I convert the int64 of format yyyymmdd into DateTime in Google Big Query?

My target column is TIMESTAMP.

Advertisement

Answer

Use parse_timestamp() and convert the value to a string:

select parse_timestamp('%Y%m%d', cast(20100101 as string))

You can also use parse_date() and parse_datetime() if those are the destination types.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement