I have sample data as follows:
ship_id | origin_zone | dt_local
1234 | Asia/Taipei| 2022-03-31 00:00:00.000
The goal is to convert dt_local into UTC. Here is my SQL for that:
select
origin_zone,
dt_local,
convert_timezone('UTC', origin_zone, dt_local) as utc_time
from table;
Please see the screenshot for the output. It seems it is just adding an offset of 8 hours to this time, which doesn't sound true. Taipei is 8 hrs ahead of UTC, so I am expecting it to subtract 8 hours from dt_local column.
I think that because I'm running this query in America/Los Angeles time (which is 8 hrs behind UTC), it's just adding 8 to the dt_local time column.
Can I please get some help on how to get the correct UTC time for this column?

You have the source and target timezones reversed. It should be:
select
origin_zone,
dt_local,
convert_timezone(origin_zone, 'UTC', dt_local) as utc_time
from table;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With