How do I display SQL column in date format which is in bigint?
I am not looking to convert each row for example
select dateadd(second, 1358523245140/1000+8*60*60, '19700101') from tablename
How do I display SQL column in date format which is in bigint?
I am not looking to convert each row for example
select dateadd(second, 1358523245140/1000+8*60*60, '19700101') from tablename
To display in a recognizable date format just add the desired format style on top of that calculation. e.g.
select
dateadd(second, 1358523245140/1000+8*60*60, '19700101')
, convert(varchar, dateadd(second, 1358523245140/1000+8*60*60, '19700101') ,121)
;
The first column will display in the database default format (e.g. January, 18 2013 23:34:05+0000) , the second column will display is style 121 (2013-01-18 23:34:05.000)
There are many tables of these styles available, or in SQL 2012 you can use the FORMAT()
e.g. http://msdn.microsoft.com/en-us/library/ms187928.aspx
http://www.sql-server-helper.com/sql-server-2012/format-function-vs-convert-function.aspx
ps: there is another method for converting that 13 digit unix timestamp to TSQL datetime here: Convert unix epoch timestamp to TSQL timestamp