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.
| Author |
Topic |
|
ninel
Posting Yak Master
141 Posts |
Posted - 2008-05-30 : 13:48:09
|
I have a field that displays seconds. I need to convert it to hours/min/sec.For example, Seconds convertedValue90 1 min 30 sec 60 1 min 0 sec95 1 min 35 sec Is this possible? Or maybe this would be easier:Seconds convertedValue90 00:01:3060 00:01:0095 00:01:35 Thanks,Ninel |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-30 : 14:16:18
|
| http://www.sqlservercurry.com/2008/03/how-to-convert-seconds-to-hhmmss.html |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2008-05-30 : 18:18:44
|
| [code]select MySeconds, MyTime = case when MySeconds < 86400 then convert(varchar(8),dateadd(ss,MySeconds,0),108) else convert(varchar(20),datediff(hour,0,dateadd(ss,MySeconds,0)))+ right(convert(varchar(8),dateadd(ss,MySeconds,0),108),6) endfrom ( --TestData select MySeconds = 86400*20 union all select MySeconds = 86400 union all select MySeconds = 86399 union all select MySeconds = 60 union all select MySeconds = 90 union all select MySeconds = 95 ) aResults:MySeconds MyTime ----------- -------------------------- 1728000 480:00:0086400 24:00:0086399 23:59:5960 00:01:0090 00:01:3095 00:01:35(6 row(s) affected)[/code]CODO ERGO SUM |
 |
|
|
|
|
|
|
|