Yesup
 
 

Yamabay Knowledge Base

 

Deal with Daylight Saving Time Offset in SQL Server 2000 Stored Procedure

Previous Article Back to TOC Next Article

In order to use consistent syntax to deal with daylight saving time in stored procedure, we can do:


line 1: Declare @hourdiff int
line 2: set @hourdiff = datediff(hour, getutcdate(), getdate())
line 3: print 'UTC hour diff: ' + Str(@hourdiff)
line 4: print 'Use UTC to get Current Time: ' + Convert(varchar(50), dateadd(hour , @hourdiff, getutcdate()) )


In the above T-SQL code, @hourdiff is the number of hours the local time.lagging the UTC.

Yesup
Top Stories Travel Movies Gift Ideas Free Software Games