Skip to content

Instantly share code, notes, and snippets.

@uuklanger
Last active August 23, 2017 18:53
Show Gist options
  • Save uuklanger/7c114e70317413e0d0057888348c0a8a to your computer and use it in GitHub Desktop.
Save uuklanger/7c114e70317413e0d0057888348c0a8a to your computer and use it in GitHub Desktop.
Determine the timezone of the SQL Server
DECLARE @TimeZone VARCHAR(50)
EXEC MASTER.dbo.xp_regread 'HKEY_LOCAL_MACHINE',
'SYSTEM\CurrentControlSet\Control\TimeZoneInformation',
'TimeZoneKeyName',@TimeZone OUT
SELECT @TimeZone
-- OR this snippet but I am not sure I trust it yet....
DECLARE @TZ SMALLINT
SELECT @TZ=DATEPART(TZ, SYSDATETIMEOFFSET())
SELECT CAST(@TZ/60 AS VARCHAR(5))+ ':' +Cast(ABS(@TZ)%60 AS VARCHAR(5));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment