How do I convert a sql bignit column in a table into days:hours:minutes:seconds
For example: (below) is the targeted column from the table and two rows of data:
time_Left
516542000
604744000
How do I convert or Cast all the data in the column to display as Days:Hours:Minutes:Seconds?
I've tried to convert it to datetime2, varchar, digit, decimals and datetime and I either get an error message or a string of digits. I'm looking for something to give me a break down of how many days:hours:minutes:Seconds the time_left is or hours:minutes:Seconds.
2条答案
按热度按时间3qpi33ja1#
If they are unix timestamps they are seconds from 1/1/1970.
If so, then you can convert with
DATEADD(SECOND, 516542000, '1970-01-01')
.Also refer to this Convert Datetime to Unix timestamp for the reverse process.
e7arh2l62#
If this column contains seconds then you can do it as follows :
FLOOR()
to return the largest integer value.Demo here