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
WITH `project.dataset.table` AS (
  SELECT CURRENT_DATE() AS dt
)
SELECT dt, CAST(dt AS TIMESTAMP) AS ts,
  TIMESTAMP(dt) AS ts2
FROM `project.dataset.table`   

Result:

Row dt          ts                           ts2
1   2018-06-13  2018-06-13 00:00:00.000 UTC  2018-06-13 00:00:00.000 UTC       

Asran

posted on 17 Sep 18

Enjoy 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