tags:

views:

601

answers:

3

In sybase is there any built in functions to convert a seconds value into hours, minutes, and seconds?

+2  A: 

I don't know if there is such a function, but if there isn't, the simple formulae are:

 HH = floor(seconds / 3600)
 MM = floor(seconds / 60) % 60
 SS = seconds % 60
Alnitak
+1  A: 

If it's value limited by 1 day, you can use this:

datepart(hour, dateadd(second, value, '1900-01-01'))
datepart(minute, dateadd(second, value, '1900-01-01'))
datepart(second, dateadd(second, value, '1900-01-01'))
Max Gontar
A: 

A common 'seconds' dimension is 'seconds since the unix epoch' or 'time_t'. If this is what you are referring to you can do something like

select dateadd(SECOND, 123456, '1970-01-01')

and you will have a datetime value which can be deconstructed into the various parts via DATEPART

pjjH

Paul Harrington