Wednesday, January 25, 2006

More time crap in SQL

I swear, I'm going to be the datetime king when I'm through with these projects in SQL...

We have installations of IBM OnDemand here that log all their actions internally. For some reason, someone decided to use arstime as a timestamp, rather than a standard datetime format. Nice. Which, by the way, is not standard unix time. arstime is number of seconds since 12/31/69, 7:00 PM. Unix time is seconds since 1/1/1970, 12:00 AM. Why they need the extra 5 hours, I have no idea.

Anyway, here's what I came up with:

dateadd(ss, time_stamp, 'Dec 31 1969 7:00 PM')

Use that as the input for your 'real time' column, when parsing logs from OnDemand. the actual view would look like this:

CREATE VIEW dbo.IM02_od_10_load_fail
AS
SELECT TOP 10 time_stamp, dateadd(ss, time_stamp, 'Dec 31 1969 7:00 PM') as realtime, userid, msg_text
FROM odadmin.SL2
WHERE (msg_num = 88)
ORDER BY time_stamp DESC

I B Slick.

1 comment:

Karen said...

You be slick.