CJSmith dot me

I dump stuff I find useful here

T-SQL Get current Unix Time

Published / by Chris Smith / Leave a Comment

The following allows you to work out the current time on the Unix Environment. The Datediff function is used to work out the number of seconds between 01/01/1970 and the current date.
I have used this against data which is stored and as Unix time.

--Get current Unix datetime
SELECT DATEDIFF(s, '1970-01-01 00:00:00', GETUTCDATE()) as UnixTime
Select dateadd(S, , '1970-01-01')

Other resources for T-SQL Dates:

Leave a Reply