SQL Column Numeric to DATE

88 views Asked by At

I am trying to convert numeric column (with 13 digits) to DATE and all i can do is this so i can see the date as a string.

CONVERT(VARCHAR(10),(DATEADD(SECOND, Start_Date/1000 ,'1/1/1970')),104)

What can i do so this will end up like DATE so i can filter it later?

The database is MS SQL.

Thanks in advance!

1

There are 1 answers

0
Gordon Linoff On BEST ANSWER

This expression should convert it to a datetime:

DATEADD(SECOND, Start_Date/1000 , '1970-01-01)

If you want a date, just convert this to a date:

CAST(DATEADD(SECOND, Start_Date/1000 , '1970-01-01') as DATE)

Note: I changed the date format to the ISO standard YYYY-MM-DD format.