如何在Google BigQuery中将时间戳转换为日期数据类型 [英] How to convert Timestamp to Date Data Type in Google Bigquery
本文介绍了如何在Google BigQuery中将时间戳转换为日期数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
bq query -q --destination_table = NEW_DATE_TABLE --replaceSELECT DATE(CURR_DT) AS CURR_DT from TEST.DATE_TABLE
新表格将该列显示为STRING而不是日期。有没有办法将时间戳转换为日期数据类型。
解决方案
如果您使用 Standard SQL ,您可以执行以下操作:
SELECT * REPLACE(EXTRACT(DATE FROM curr_dt))AS curr_dt FROM test.date_table
$ p $ SELECT $ REPLACE
ARRAY (
SELECT EXTRACT(date from curr_dt)FROM t.curr_dt
)AS curr_dt)
FROM test.date_table t
I am trying to convert Timestamp data type columns to Date datatype using:
bq query -q --destination_table=NEW_DATE_TABLE --replace "SELECT DATE(CURR_DT) AS CURR_DT from TEST.DATE_TABLE"
The new table shows the column as STRING rather than date. Is there a way to convert timestamp to date datatype.
解决方案
If you use Standard SQL, you can do the following:
SELECT * REPLACE(EXTRACT(DATE FROM curr_dt)) AS curr_dt FROM test.date_table
If curr_dt is repeated field, then the solution will look the following:
SELECT * REPLACE(
ARRAY(
SELECT EXTRACT(DATE FROM curr_dt) FROM t.curr_dt
) AS curr_dt)
FROM test.date_table t
这篇关于如何在Google BigQuery中将时间戳转换为日期数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文