Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2001-10-16 : 16:55:49
|
michael harber writes "Not a question but I thought I'd share a cool Stored Procedure I created to determine the DST begin and end for the current year and whether it is in effect (2 steps)(STEP 1:)CREATE PROCEDURE DST( @LocalTime datetime, @DSTStart datetime OUTPUT, @DSTStop datetime OUTPUT, @DSTActive char(1) OUTPUT)AS DECLARE @DSTBegin varchar(100) DECLARE @DSTEnd varchar(100) SET @DSTBegin = '4-01-' + convert(char(4),DatePart(yyyy,GetDate())) + ' 02:00:00' SET @DSTEnd = '11-01-' + convert(char(4),DatePart(yyyy,GetDate())) + ' 02:00:00' WHILE datepart(w, @DSTBegin) <> 1 BEGIN SET @DSTBegin=DateAdd(day, 1,@DSTBegin) END WHILE datepart(w, @DSTEnd) <> 1 BEGIN SET @DSTEnd=DateAdd(day,-1,@DSTEnd) ENDSET @DSTStart = @DSTBeginSET @DSTStop = @DSTEndIF @LocalTime >= @DSTBegin AND @LocalTime < @DSTEnd SET @DSTActive = 'Y'ELSE SET @DSTActive = 'N'RETURNGO(STEP 2:)Declare @DST char(1), @DSTBegin datetime, @DSTEnd datetime, @Now datetime, @DSTStart datetime, @DSTStop datetime, @DSTActive char(1)exec dst '10-28-2001 2:00:00', @DSTStart=@DSTBegin OUTPUT, @DSTStop=@DSTEnd OUTPUT, @DSTActive=@DST OUTPUTSelect @DSTBegin, @DSTEnd, @DST " |
|
|
|
|
|
|