Reputation: 3
I want convert seconds to days, hour, minutes seconds.
I use query like that.
select to_char(to_timestamp(2042658), 'dd "Days" HH24 "Hours" MI "Minutes" SS "Seconds"') as uptime
But that gives me 24 days, should be 23 and 18 hours should be 15. What is right solution do it.
Upvotes: 0
Views: 1266
Reputation: 31656
use TO_CHAR
with justify_hours
select to_char(justify_hours(interval '1 sec' * 2042658),
'DD" days "HH24" hours "MI" minutes "SS" seconds"') as uptime
Upvotes: 1