Epoch Date
From Wiki
Unix time, or POSIX time, is a system for describing points in time: it is the number of seconds elapsed since midnight UTC of January 1, 1970, not counting leap seconds
Here is how you do it in SQL Server. To get the Unix time for now run this
- SELECT all
- SELECT DATEDIFF(s,'19700101 05:00:00:000',GETUTCDATE())
To get the Unix time for January 1, 2001 run this
- SELECT all
- SELECT DATEDIFF(s,'19700101 05:00:00:000','20000101 05:00:00:000')
We need to add 5 hours to 20000101, if you are running this from a GMT-5 timezone (I am based in Princeton, NJ which is 5 hours behind GMT)
Contributed by: --SQLDenis 16:52, 30 May 2008 (GMT)
Part of SQL Server Programming Hacks
Section Dates


