How to get Current TimeZone Name in SQL Server?

+1 vote
14 views
asked Nov 1 by Hitesh Garg (251 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 by Rahul Singh (328 points)  
selected Nov 1 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** 

41 questions

27 answers

3 comments

20 users

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