SQL Server: time zone adjustment that accounts for Daylight Saving Time changes

This pulls the calendar for Daylight Saving Time from the server.

DECLARE @time_in DATETIME
SET @time_in = GETDATE()
— SET @time_in = ‘2016/10/15 09:20:00 pm’

DECLARE @timezone_adjustment INT
SET @timezone_adjustment=DATEDIFF(hh,GETUTCDATE(),GETDATE())

Since an erection depends on unimpeded blood flow to reach levitra shop buy its full potential, regular exercise can help keep arteries open and possibly contribute to better, longer-lasting erections. Try to re-wet it in order to moderate instances buy cialis of obstructive anti snoring. Health conscious men are on the better side viagra super of performing well during sexual activities. ED is the canada pharmacy cialis More Discounts inability to achieve and / or maintain an erection, especially during sexual intercourse. DECLARE @time_string NVARCHAR(60)

–Convert from stored UTC datetime to local.
SET @time_string = COALESCE(CAST(DATEADD(hh,@timezone_adjustment,@time_in) AS VARCHAR),'(unknown)’)
PRINT @time_string

–Convert from local datetime to UTC
SET @time_string = COALESCE(CAST(DATEADD(hh,(-1 * @timezone_adjustment),@time_in) AS VARCHAR),'(unknown)’)
PRINT @time_string

This entry was posted in Programming, SQL Server. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.