epoch conversion and time zone offset

Giganews Newsgroups
Subject: epoch conversion and time zone offset
Posted by:  migurus (migur…@yahoo.com)
Date: Fri, 22 Oct 2010

I have input data with date in epoch format (seconds since the
beginning...),
I am trying to convert it to visual representation and the local time
zone is playing tricks on me.

declare @dt as datetime;
declare @ss as int;

set @ss = 1287783600 -- my input for 2010-10-22 14:40
set @dt = '2010-10-22 14:40:00.000'

select @ss as [Epoch], DATEADD(s, @ss, '19700101 00:00:00') as [CALC],
@dt as [ACTUAL]

Output:
Epoch      CALC                    ACTUAL
----------- ----------------------- -----------------------
1287783600  2010-10-22 21:40:00.000 2010-10-22 14:40:00.000

There are 7 hours difference between Actual date and calculated, which
is our local time zone offset now.

How do I convert it so calculated date is equal to my input?
Running on SQL2005,
thanks.

Replies