简体   繁体   English

如何在 BigQuery 中使用“Mon May 11 2020 11:22:19 GMT+0000(协调世界时)”作为日期

[英]How to use "Mon May 11 2020 11:22:19 GMT+0000 (Coordinated Universal Time)" as a date in BigQuery

Is it possible to make a query to convert "Mon May 11 2020 11:22:19 GMT+0000 (Coordinated Universal Time)" to a date format such as YYYY-MM-DD within BigQuery?是否可以查询将“2020 年 5 月 11 日星期一 11:22:19 GMT+0000(协调世界时)”转换为日期格式,例如 BigQuery 中的 YYYY-MM-DD?

Or the data format has to be converted before querying in BigQuery?或者在BigQuery中查询之前必须转换数据格式?

Below for BigQuery Standard SQL下面是 BigQuery 标准 SQL

SELECT DATE(PARSE_TIMESTAMP('%a %b %d %Y %X GMT%z', SUBSTR("Mon May 11 2020 11:22:19 GMT+0000 (Coordinated Universal Time)", 1, 33)))   

with output output

2020-05-11

You can use this resource:您可以使用此资源:

SELECT CURRENT_DATE([time_zone])

Returns: 2016-12-25退货时间: 2016-12-25

You can add an optional time zone as an argument to this function. It will return date in UTC time zone if you don't pass the argument.您可以添加一个可选时区作为此 function 的参数。如果您不传递参数,它将返回 UTC 时区的日期。

Resource: Google BigQuery standard SQL docs资源: Google BigQuery 标准 SQL 文档

Check this resource if you want to learn more.如果您想了解更多信息,请查看此资源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM