Last active
December 15, 2016 01:26
-
-
Save andreasbotsikas/977c6471e073a16ec00544bf9cc55a8b to your computer and use it in GitHub Desktop.
SQL convert unix timestamp to date
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- To select min max dates | |
select | |
dateadd(S, min([time])/1000, '1970-01-01') as startdate, | |
dateadd(S, max([time])/1000, '1970-01-01') as enddate | |
FROM HistoricTable | |
-- To add a calculated column per row | |
BEGIN TRANSACTION | |
GO | |
ALTER TABLE HistoricTable ADD | |
ConvertedDate AS (dateadd(second,[time]/(1000),'1970-01-01')) | |
GO | |
COMMIT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment