I found this thread and thought it was worth repeating. My email-to-blog had a link to the original posts, but apparently it didn't come through.
Original Post: I have stored, as seconds, a duration in a table. I would like to use a SELECT statement to retrieve the contents of the column but display them as a time. For example:
45 = 0:00:45
241 = 0:04:01
575 = 0:09:35
and so on...
Original Post: I have stored, as seconds, a duration in a table. I would like to use a SELECT statement to retrieve the contents of the column but display them as a time. For example:
45 = 0:00:45
241 = 0:04:01
575 = 0:09:35
and so on...
---
Answer:
declare @seconds int
set @seconds = 241
select convert(char(8), dateadd(second, @seconds, ''), 114)
set @seconds = 241
select convert(char(8), dateadd(second, @seconds, ''), 114)
---
Response:
Thanks for this.
I took your example and turned it in to this which works:
SELECT CONVERT(char(8), DATEADD(second, Duration, ''), 114) AS Duration
No comments:
Post a Comment