Skip to content

Instantly share code, notes, and snippets.

@sawilde
Last active March 2, 2019 01:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sawilde/45f64f121945d36750462fed644c5b48 to your computer and use it in GitHub Desktop.
Save sawilde/45f64f121945d36750462fed644c5b48 to your computer and use it in GitHub Desktop.
Converting UTC to Local time on SQL
-- 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