Offsetting the time zone in MS SQL 2005

I needed to offset the current time in MS SQL 2005 for a quick fix. I wanted to make sure the solution would not have to be maintained when daylight savings time changed. Taking the difference between the GETUTCDATE() and GETDATE() functions will generate the server’s current time zone offset from UTC time.

DECLARE @timezoneOffset INT
SELECT @timezoneOffset = (DATEDIFF(hh,GETDATE(),GETUTCDATE())) * -1;
SELECT DATEADD(hh, @timezoneOffset, GETUTCDATE()), GETDATE()

1 thought on “Offsetting the time zone in MS SQL 2005

  1. Pingback: Tweets that mention aaronkjackson.com » Offsetting the time zone in MS SQL 2005 -- Topsy.com

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.