How can I convert bigint (UNIX timestamp) to datetime in SQL Server?

salman picture salman · May 25, 2010 · Viewed 288.2k times · Source

How can I convert UNIX timestamp (bigint) to DateTime in SQL Server?

Answer

Daniel Little picture Daniel Little · Nov 23, 2011

This worked for me:

Select
    dateadd(S, [unixtime], '1970-01-01')
From [Table]

In case any one wonders why 1970-01-01, This is called Epoch time.

Below is a quote from Wikipedia:

The number of seconds that have elapsed since 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970,[1][note 1] not counting leap seconds.