[英]convert timestamp timezone to datetime with another time zone in Bigquery
I have an external table (from GCS) in bigquery that by auto scheme detect a datetime column and creates a timestamp column in the table with UTC.我在 bigquery 中有一个外部表(来自 GCS),它通过自动方案检测日期时间列并在表中使用 UTC 创建时间戳列。 The time zone of my data is Central (America/Chicago).我数据的时区是中部(美国/芝加哥)。
I know that the timezone is central and I want to create another column with UTC timezone.我知道时区是中央时区,我想用 UTC 时区创建另一个列。 I tried using parse_timestamp/converting to string then to datetime with timezone.我尝试使用 parse_timestamp/转换为字符串然后转换为带时区的日期时间。 But couldn't get it right.但是无法正确处理。 Any suggestion?有什么建议吗?
The following query will output the correct UTC time.下面的查询会得到 output 正确的 UTC 时间。 Remember that BigQuery stores timestamps in UTC.请记住,BigQuery 以 UTC 格式存储时间戳。
with sample as (
select timestamp('2021-01-10 08:00:00', 'UTC') as ts
)
select timestamp(datetime(ts), 'America/Chicago') from sample;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.