我正在查询关于BigQuery的表格,该表格在“DATE”中有一个字段。格式。我想在' TIMESTAMP'中读到这个。格式。我尝试将DATE转换为整数,然后转换为TIMESTAMP但似乎没有效果。
答案 0 :(得分:2)
#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`
结果为
Row dt ts ts2
1 2018-06-13 2018-06-13 00:00:00.000 UTC 2018-06-13 00:00:00.000 UTC