Toti
asked on
How to convert seconds to hh:mm:ss in a sql query
Hi.
I'm new to this but can anyone help me with how to convert seconds to hours:minutes:seconds in a sql query.
My query is like this:
"select duration from tablename"
The column duration returns seconds and I want to format it in to hh:mm:ss in the statement.
Thanks.
Toti
I'm new to this but can anyone help me with how to convert seconds to hours:minutes:seconds in a sql query.
My query is like this:
"select duration from tablename"
The column duration returns seconds and I want to format it in to hh:mm:ss in the statement.
Thanks.
Toti
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Excellent answer and does the job.
However if I want to add number of days in front of hours so the display would be like this dd:hh:mm:ss or for that matter yy:mm:dd:hh:mm:ss. What would that sql script look like?
The thing is that I'm using this script on Call Detail Records in a Phone System for a summation of call time. In a year period total talk time would be measured in the above scale.
Regards Toti
However if I want to add number of days in front of hours so the display would be like this dd:hh:mm:ss or for that matter yy:mm:dd:hh:mm:ss. What would that sql script look like?
The thing is that I'm using this script on Call Detail Records in a Phone System for a summation of call time. In a year period total talk time would be measured in the above scale.
Regards Toti
select @i = 1234
select convert( char(8), dateadd( ss, @i, '00:00:00' ), 108 )