Home > Mobile >  convert timestamp timezone to datetime with another time zone in Bigquery
convert timestamp timezone to datetime with another time zone in Bigquery

Time:09-30

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. The time zone of my data is Central (America/Chicago). enter image description here

I know that the timezone is central and I want to create another column with UTC timezone. I tried using parse_timestamp/converting to string then to datetime with timezone. But couldn't get it right. Any suggestion?

CodePudding user response:

The following query will output the correct UTC time. Remember that BigQuery stores timestamps in UTC.

with sample as (
    select timestamp('2021-01-10 08:00:00', 'UTC') as ts
)
select timestamp(datetime(ts), 'America/Chicago') from sample;
  • Related