Click here to Skip to main content
15,867,594 members
Articles / Database Development / SQL Server

Checking the New DST 2007 from a DBA Perspective

Rate me:
Please Sign up or sign in to vote.
4.14/5 (3 votes)
31 Jan 20071 min read 26.1K   243   15   1
How to check if your Microsoft SQL Server 2005 is ready for the new DST 2007

Preamble

As a result of the Energy Policy Act that was passed in August 2005 by the United States Congress, there is a change in the daylight saving time starting from 2007 as follows:

Previous DST (begin) New DST (begin) Previous DST (end) New DST (end)
1st Sunday of April 2nd Sunday of March Last Sunday of October 1st Sunday of November
April 1, 2007 March 11, 2007 October 28, 2007 November 4, 2007

This document shows you how to check if your Microsoft SQL Server 2005 is ready for the new DST 2007.

Technical Details

The managed assembly ConvertTime.dll contains 1 stored procedure (ufnDisplayUTC) and 2 functions (ufnToLTime, and ufnToUTime) as follows:

  • ufnDisplayUTC displays information about the current DST. For example:
    Timezone: . . . . . . Eastern Standard Time
    New DST for 2007: . . 2007-03-11 02:00 to 2007-11-04 02:00 (01:00:00)
    Current time: . . . . 1/31/2007 11:30:32 AM
    Universal time: . . . 1/31/2007 4:30:32 PM
    UTC offset: . . . . . -05:00:00
    Daylight saving? . . No
  • ufnToUTime(@strDateTime) returns the universal date and time of a given local date and time. For example:
    SQL
    select dbo.ufnToUTime('2007-03-11 02:00:00.000')
    --3/11/2007 7:00:00 AM
  • ufnToLTime(@strDateTime) returns the local date and time of a given universal date and time. For example:
    SQL
    select dbo.ufnToLTime('2007-03-11 07:00:00.000')
    --3/11/2007 3:00:00 AM

Implementation

Execute the following script within the Microsoft SQL Server Management Studio for a database such as AdventureWorks:

SQL
CREATE ASSEMBLY [ConvertTime]
FROM 'ConvertTime.dll'
WITH PERMISSION_SET = SAFE
GO
CREATE FUNCTION [dbo].[ufnToLTime](@strDateTime [nvarchar](4000))
RETURNS [nvarchar](4000) WITH EXECUTE AS CALLER
AS EXTERNAL NAME [ConvertTime].[MCSCS.SQL2005.UserDefinedFunctions].[ufnToLTime]
GO
CREATE FUNCTION [dbo].[ufnToUTime](@strDateTime [nvarchar](4000))
RETURNS [nvarchar](4000) WITH EXECUTE AS CALLER
AS EXTERNAL NAME [ConvertTime].[MCSCS.SQL2005.UserDefinedFunctions].[ufnToUTime]
GO
CREATE PROCEDURE [dbo].[ufnDisplayDST]
AS
EXTERNAL NAME [ConvertTime].[MCSCS.SQL2005.UserDefinedFunctions].[ufnDisplayDST]
GO

Testing

If your server has not been patched with the new DST 2007, you will observe the following result:

SQL
select dbo.ufnToUTime('2007-03-11 02:00:00.000')
--3/11/2007 7:00:00 AM
SQL
select dbo.ufnToUTime('2007-03-11 03:00:00.000')
--3/11/2007 8:00:00 AM

However, if your server has been patched with the new DST 2007, you will observe the following result:

SQL
select dbo.ufnToUTime('2007-03-11 02:00:00.000')
--3/11/2007 7:00:00 AM
SQL
select dbo.ufnToUTime('2007-03-11 03:00:00.000')
--3/11/2007 7:00:00 AM

Conclusion

For more information on how to patch your server, please check out the following URL: http://www.microsoft.com/windows/timezone/dst2007.mspx.

History

  • 31st January, 2007: Initial post

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Canada Canada
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionSQL Server 2000 Pin
smoore49-Feb-07 6:29
smoore49-Feb-07 6:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.