From: Janet on
I've been running the following to convert SQL time into Unix time:
select DATEDIFF(s, '19700101', end_date), end_date, start_date,
event_sub_type, courseid
from training.dbo.classes
where courseid like 'HLH 110.R031%'

However, it isn't taking into account the timezone - I need the unix
timestamp to take into account Eastern Time (GMT -5) so that when
translated taking into account timezone it comes out as such.

For example, given the SQL timestamp 2010-01-14
my script returns 1263427200 (when translated as GMT this is Jan 14,
but with the -5 for ET, it comes out to Jan 13)
but I need it to return something like 1263445200 (which with the -5
for ET, comes out to Jan 14)...

any ideas on how to do this in SQL? I only need to run it once.


From: Plamen Ratchev on
You can add the 5 hours with DATEADD:

SELECT DATEDIFF(s, '19700101', DATEADD(HOUR, 5, end_date)),
end_date,
start_date,
event_sub_type,
courseid
FROM training.dbo.classes
WHERE courseid LIKE 'HLH 110.R031%';

--
Plamen Ratchev
http://www.SQLStudio.com
From: Janet on
So easy and clean! Perfect! Thanks!