I have a timezone name like America/Vancouver saved in MSSQL database. I want to get the UTC offset from the timezone name in SQL like America/Vancouver has -08:00 offset. So how can I write a query in SQL? Your help is much appreciated
America/Vancouver
-08:00
Use DATEPART with TZ parameter. Example :
SELECT DATEPART(tz, (CAST('2021-01-01' AS DATETIMEOFFSET) AT TIME ZONE 'Central European Standard Time'));
The result is in minutes.
1.4m articles
1.4m replys
5 comments
57.0k users