How to cast DATE Column to TIMESTAMP in BigQuery
Solution:
Use the CAST Function CAST(DATE_COLUMN as TIMESTAMP) or just TIMESTAMP(date_column)
#standardSQL\nWITH `project.dataset.table` AS (\n SELECT CURRENT_DATE() AS dt\n)\nSELECT dt, CAST(dt AS TIMESTAMP) AS ts,\n TIMESTAMP(dt) AS ts2\nFROM `project.dataset.table` \n
\n\nResult:
\n\nRow dt ts ts2\n1 2018-06-13 2018-06-13 00:00:00.000 UTC 2018-06-13 00:00:00.000 UTC \n
Asran
posted onEnjoy great content like this and a lot more !
Signup for a free account to write a post / comment / upvote posts. Its simple and takes less than 5 seconds
Post Comment