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 |
|
AlanPBates
Starting Member
34 Posts |
Posted - 2010-05-07 : 15:48:48
|
| How do I convert seconds obtained from a table to hh:mm format in a query ?Thanks,Alan |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
AlanPBates
Starting Member
34 Posts |
Posted - 2010-05-07 : 16:11:03
|
| Thanks Tara .. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2010-05-07 : 18:05:51
|
| [code]declare @seconds intset @seconds = 18422select [HH:MM] = convert(varchar(5),dateadd(ss,@seconds,0),108)[/code]Results:[code]HH:MM ----- 05:07[/code]CODO ERGO SUM |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2010-05-07 : 19:13:04
|
| The OP didn't really say what they wanted to do with leftover seconds. The solution I posted just discards them, but you could do regular rounding by adding 30 to the total number of seconds.I assumed the time will not be >= 86400 (24 hours). If it is, there would have to be some adjustment.CODO ERGO SUM |
 |
|
|
|
|
|
|
|