Reputation: 562
I'm requiring assistance in converting seconds to a more readable format and hence needing help converting it.
For example, if my columns are giving the following output (in seconds):
156
253
20
85
95
252
I need to turn this into something like this:
02:36
04:13
00:20
01:25
01:35
04:12
My Query producing this output:
datediff([second], (Select TOP 1 [ActualStart]
from Runtime_CTE
where HelperObjectID = [Report ID] ORDER BY ActualStart DESC),
[Previous Run]) as [Run Time]
Could someone help me out in updating my query?
Thanks.
Upvotes: 1
Views: 84
Reputation: 96028
Add the value to the time midnight:
SELECT DATEADD(SECOND, YourColumn, CONVERT(time(0), '00:00')) AS TimeValue
FROM YourTable...
For example, the value 156
returns 00:02:36
:
SELECT DATEADD(SECOND, 156,CONVERT(time(0), '00:00'));
Upvotes: 6