first_page the funky knowledge base
personal notes from way, _way_ back and maybe today

SQL Server 2000: UTC datetime values; GETUTCDATE()

From Eron Wright's Blog: "You can convert local datetime values to UTC datetime values, and vice-versa, using the built-in GETUTCDATE() function:"

DECLARE @LocalDate DATETIME
SET @LocalDate = GETDATE()

-- convert local date to utc date
DECLARE @UTCDate DATETIME
SET @UTCDate = DATEADD(Hour,DATEDIFF(Hour,GETUTCDATE(), GETDATE()),@LocalDate)

-- convert utc date to local date
DECLARE @LocalDate2 DATETIME
SET @LocalDate2 = DATEADD(Hour, DATEDIFF(Hour, GETDATE(), GETUTCDATE()), @UTCDate)
SELECT @LocalDate, @UTCDate, @LocalDate2

"Note that GETUTCDATE() returns the current datetime in UTC. By comparing the value with GETDATE() we can determine the time zone, which can then be used to adjust any date." For more information see:

http://geekswithblogs.net/ewright/archive/2004/09/14/11180.aspx
mod date: 2006-01-14T17:52:53.000Z