Cozzamara
Cozzamara

Reputation: 1338

Time zone name in SQL Server 2008

Is it possible to get the name of the current time zone, such as "Eastern Standard Time" or "EST" in SQL code on SQL Server 2008 R2 ? I know I can determine numeric local time offset by calculating difference between getdate() and getutcdate(), but that's not what I need. I simply need TZ name from the underlying operating system.

Upvotes: 0

Views: 7492

Answers (1)

Raj
Raj

Reputation: 10853

Without any defined table, if you just want to read the time zone information from the System Information, then it can be read from the system registry.

declare @TZName varchar(50)

exec master.dbo.xp_regread 'HKEY_LOCAL_MACHINE',
'SYSTEM\CurrentControlSet\Control\TimeZoneInformation',
'TimeZoneKeyName',@TZName OUT

select @TZName

Raj

Upvotes: 4

Related Questions