Static Pages

Tuesday, October 12, 2010

UNIX Date Format for SQL Server

UNIX date times are most often stored as seconds from midnight, January 1, 1970. If you are running into a date format that looks like, for example, "1286790650" or "1141541097", a ten digit number, it is most likely a UNIX time stamp. (also see http://en.wikipedia.org/wiki/Unix_time ).

Here's how to convert on SQL Server:
dateadd(ss, 1234567890, '1970-01-01')
where 12345678790 is your date given in UNIX time stamp format.

This is also why 11:31 pm (in the UK) was so exciting on February 13, 2009.

No comments:

Post a Comment