Click to See Complete Forum and Search --> : Inline seconds to time conversion


Octavo
May 28th, 2004, 05:10 AM
OK, I have a really awful select query which returns a value in seconds as one of the columns.

I need to modify this query to display the seconds value as a time value formatted HH:mm:ss

The restriction I'm working under is that I can't write other queries or anything else, it all HAS to be done within this single query.

Ok, so I've got the algorithm I want to use to get the seconds to time -- (SecVal \ 3600) & ":" & ((secVal Mod 3600) \ 60) & ":" & SecVal Mod 60

So I got the first bit to divide the hours right, but when I try to concatenate a ":" I get this error:
Syntax error converting the varchar value ':' to a column of data type int

This is the code I'm using
Cast(((sum(totalDuration) / 3600) + ':') as varchar) as [Total Duration]

Please help

hspc
May 28th, 2004, 10:04 AM
try :

(Cast((sum(totalDuration) / 3600) as varchar) + ':') as [Total Duration]

Octavo
May 28th, 2004, 10:10 AM
D'oh!

I should have seen the logic there. Thanks dude - problems solved

Woot!