Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
How to Convert Seconds (i.e., 114) to hh:mm:ss format,is there any way.. i've a column (DURATION) which is recorded in SecondsAND USER wants to see the seconds in hh:mm:ss 00:14:28 pls.helpthanks
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts
Posted - 2008-04-28 : 17:49:47
This will do it.If your DURATION is >= 86400 hours (one day), you will need to take a different approach.
select DURATION, [HH:MM:SS] = convert(varchar(20),dateadd(ss,a.DURATION,0),108)from ( -- Test Data select DURATION = 0 union all select DURATION = 111 union all select DURATION = 86399 ) aResults:DURATION HH:MM:SS ----------- -------------------- 0 00:00:00111 00:01:5186399 23:59:59(3 row(s) affected)