Last active
March 2, 2019 01:49
-
-
Save sawilde/45f64f121945d36750462fed644c5b48 to your computer and use it in GitHub Desktop.
Converting UTC to Local time on SQL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- I acknowledge that someone showed me this and I have stolen it :) | |
declare @tz varchar(100) = 'AUS Eastern Standard Time'; | |
--declare @tz varchar(100) = 'GMT Standard Time'; | |
select id, update_time_utc as [updatedTimeUtc], | |
CONVERT(datetime, SWITCHOFFSET([update_time_utc], DATEPART(TZOFFSET, [update_time_utc] AT TIME ZONE @tz))) as [updatedTimeLocal] | |
from [your_table] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment