简体   繁体   English

使用Bigquery中的另一个时区将时间戳时区转换为日期时间

[英]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.

相关问题 将 UNIX 时间 (INT) 转换为 BigQuery 中的时间戳 - Convert UNIX time (INT) to timestamp in BigQuery Redshift TIMEZONE function 的意外结果(将时间戳列从 UTC 转换为另一个时区) - Unexpected result from Redshift TIMEZONE function (convert timestamp column from UTC to another timezone) BigQuery timestamp_trunc 不应用时区 - BigQuery timestamp_trunc not applying timezone 将 pyarrow 时间戳(以 ms 为单位)转换为 BigQuery 时间戳 - Convert pyarrow timestamp in ms to BigQuery timestamp 在 BigQuery 中将 TIME 转换为 INT - Convert TIME to INT in BigQuery Bigquery中的DATE(timestamp_expression[, timezone]):将UTC(2021-12-07T04:46:16Z)转换为本地时间,UTC在SQL中有T和Z。如何获取AEST? - DATE(timestamp_expression[, timezone]) in Bigquery: convert UTC (2021-12-07T04:46:16Z) to local time, UTC has T and Z in SQL. How to get AEST? Azure SQL 将“时区显示名称”转换为“时区ID” - Azure SQL Convert "Time zone display name" to "Time zone ID" 根据 BigQuery 中的时间戳计算平均时间和最大时间 - Calculate average and max time from a timestamp in BigQuery 从 BigQuery 中的时间戳或日期时间减去 6 天 23 小时 - Subtract 6 days and 23 hours from a Timestamp or Datetime in BigQuery BigQuery - 使用默认值将字符串转换为时间戳 - BigQuery - convert String to Timestamp with default value
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM