Skip to content

Instantly share code, notes, and snippets.

@fushnisoft
Last active December 13, 2015 21:19
Show Gist options
  • Save fushnisoft/4976723 to your computer and use it in GitHub Desktop.
Save fushnisoft/4976723 to your computer and use it in GitHub Desktop.
Convert SQL server DateTime stored in UTC to system DateTime
DECLARE @offset int
SET @offset = DATEDIFF(hh, GetDate(), GETUTCDATE());
SELECT GetDate() AS 'System DateTime'
, GETUTCDATE() AS 'UTC DateTime'
, @offset AS 'OffSet'
, DateAdd(hh, @offset, GetDate()) AS 'System converted to UTC'
, DateAdd(hh, @offset*-1, GetUtcDate()) AS 'UTC Converted to System'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment