How to get Current TimeZone Name in SQL Server?

+1 vote
61 views
asked Nov 1, 2017 by Hitesh Garg (343 points)  

I am trying to find the current timezone name of current SQL Server installation. Is there any query to do so?

1 Answer

+1 vote
answered Nov 1, 2017 by Rahul Singh (518 points)  
selected Nov 1, 2017 by Hitesh Garg
 
Best answer

It is easy and a single query will do the work.

DECLARE @TimeZone VARCHAR(50)
EXEC xp_regread 'HKEY_LOCAL_MACHINE',
'SYSTEM\CurrentControlSet\Control\TimeZoneInformation',
'TimeZoneKeyName',@TimeZone OUT
SELECT @TimeZone

Result -

      (No column name)
1    India Standard Time

If in the query you are not able to find the table then try appending the database and schema name as well like -

Change **xp_regread**  to **Master.dbo.xp_regread** 
Welcome to Codingeek Q&A, where you can ask questions and receive answers from other members of the community.
...