0

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.

4

1 に答える 1

4

テーブルが定義されていない場合、システム情報からタイム ゾーン情報を読み取るだけの場合は、システム レジストリから読み取ることができます。

declare @TZName varchar(50)

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

select @TZName

ラージ

于 2013-01-22T04:21:27.077 に答える