Home All Groups Group Topic Archive Search About
Author
17 Aug 2006 2:26 PM
The One
Hi,

can anyone tell me how I can tell if a machine has applied Daylight Time or
not? I need to find this out in a stored proc in both SQLServer2000 and
2005 using T-SQL.

TIA
John

Author
17 Aug 2006 2:39 PM
Roy Harvey
This will tell you the offset (in minutes) from UTC, what we used to
call Greenwich Mean Time or GMT.  Perhaps with that you can determine
if daylight time is involved.

select datediff(minute, getutcdate(),getdate())

Note that some time zones use half-hour offsets, not full hour,
otherwise this could have simply used hours instead of minutes.

Roy Harvey
Beacon Falls, CT

On Thu, 17 Aug 2006 07:26:28 -0700, The One <The***@nowhere.com>
wrote:

Show quote
>Hi,
>
>can anyone tell me how I can tell if a machine has applied Daylight Time or
>not? I need to find this out in a stored proc in both SQLServer2000 and
>2005 using T-SQL.
>
>TIA
>John
Author
17 Aug 2006 2:53 PM
The One
Roy Harvey <roy_har***@snet.net> wrote in
Show quote
news:8ov8e29b8kerbbad8fle660re4ch2cl0ku@4ax.com:

> This will tell you the offset (in minutes) from UTC, what we used to
> call Greenwich Mean Time or GMT.  Perhaps with that you can determine
> if daylight time is involved.
>
> select datediff(minute, getutcdate(),getdate())
>
> Note that some time zones use half-hour offsets, not full hour,
> otherwise this could have simply used hours instead of minutes.
>
> Roy Harvey
> Beacon Falls, CT
>
> On Thu, 17 Aug 2006 07:26:28 -0700, The One <The***@nowhere.com>
> wrote:
>
>>Hi,
>>
>>can anyone tell me how I can tell if a machine has applied Daylight
>>Time or not? I need to find this out in a stored proc in both
>>SQLServer2000 and 2005 using T-SQL.
>>
>>TIA
>>John
>
Hi Roy,

thanks, that's sorted it as I will alwyas be using GMT so I can use
datadiff(hour,getutcdate(),getdate())

John
Author
17 Aug 2006 3:05 PM
Aaron Bertrand [SQL Server MVP]
Compare DaylightBias / StandardBias / ActiveTimeBias in
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation\




DECLARE
@StandardBias VARBINARY(8),
@DaylightBias VARBINARY(8),
@ActiveBias   VARBINARY(8),
@root VARCHAR(32),
@key  VARCHAR(128);

SELECT
@root = 'HKEY_LOCAL_MACHINE',
@key = 'SYSTEM\CurrentControlSet\Control\TimeZoneInformation';

EXEC master..xp_regread @root, @key, 'StandardBias', @StandardBias OUTPUT;

EXEC master..xp_regread @root, @key, 'DaylightBias', @DaylightBias OUTPUT;

EXEC master..xp_regread @root, @key, 'ActiveTimeBias', @ActiveBias OUTPUT;

IF @StandardBias != @DaylightBias
BEGIN
PRINT 'Daylight savings time is enabled.'
IF @ActiveBias = @DaylightBias
BEGIN
  PRINT 'And daylight savings time is currently observed.';
END
ELSE
BEGIN
  PRINT 'But daylight savings time is currently not observed.';
END
END
ELSE
BEGIN
PRINT ' Daylight savings time is not enabled.';
END








Show quote
"The One" <The***@nowhere.com> wrote in message
news:Xns98229D139DCDETheOnenowhere@207.46.248.16...
> Hi,
>
> can anyone tell me how I can tell if a machine has applied Daylight Time
> or
> not? I need to find this out in a stored proc in both SQLServer2000 and
> 2005 using T-SQL.
>
> TIA
> John

AddThis Social Bookmark Button