Saturday, December 06, 2008

SQL Server - "How do I convert a timespan, in seconds, to HH:MM:SS?"

Google doesn't always have the right answers.

I wanted a quick solution to How do I convert a timespan, in seconds, to HH:MM:SS?
and the hits that came back were all like this one.... most of them from "expert sexchange" types sites (I *hate* expert sexchange!)

However, this answer is just wrong... if you have a time as a float in seconds and you want a datetime object, then use dateadd:

dateadd(ss, @numSeconds, 0)

Glad I got that off my chest!

P.S. Sorry for the lack of blog posts recently - I do actually have loads to blog about!

No comments:

Post a Comment