SQL SERVER – Get Current TimeZone Name in SQL Server

A very common question we developer often encounters is what is the current Timezone of the server where SQL Server is installed. It is very easy to get current Timezone of the server where SQL Server is installed. Here is the simple script for the same.

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

As my server is in India it will display following results.

SQL SERVER - Get Current TimeZone Name in SQL Server timezonelist

I have been using this script for a quite a while and I have no idea of the origin of this script. Is there any other way to get the Timezone for SQL Server.

Reference: Pinal Dave (https://blog.sqlauthority.com)

SQL DateTime
Previous Post
MySQL – When to Use TIMESTAMP or DATETIME – Difference Between TIMESTAMP or DATETIME
Next Post
MySQL – How to Detect Current Time Zone Name in MySQL

Related Posts

Leave a Reply