MySQL has a cool function sec_to_time() which converts your number of seconds to hh:mm:ss
I’ve read through the mailing lists and am basically trying to implement the following:
MySQL:
select sec_to_time(sum(unix_timestamp(enddate) - unix_timestamp(startdate))) from foo;
PostgreSQL:
select XXX(sum(date_part('epoch',enddate) - date_part('epoch',startdate))) from foo;
I just need to know what XXX is/can be. I’ve tried a lot of combinations of the documented functions .
Please let how to do this in PostgreSQL?
Use
to_char:Here’s a function that produces a
textformatted value:eg:
If you’d prefer an
INTERVALresult, use:… which will produce results like:
Don’t cast an
INTERVALtoTIMEthough; it’ll discard the days part. Useto_char(theinterval, 'HH24:MI:SS)to convert it totextwithout truncation instead.