Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.
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



LTD Social Sitings
Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.