Login or Sign Up to become a member!

EXPERTS, INFORMATION, IDEAS & KNOWLEDGE

Social bookmarker Add this

Epoch Date

From Wiki

Jump to: navigation, search

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

  1. SELECT all
  2.     SELECT DATEDIFF(s,'19700101 05:00:00:000',GETUTCDATE())


To get the Unix time for January 1, 2001 run this

  1. SELECT all
  2.     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

121 Rating: 1.0/5 (3 votes cast)