I'm trying to convert my seconds into the numbers of hours, days,... contained into my time.
I have tried the following request (fiddle):
SELECT TO_CHAR((1670857661 || ' second')::interval, 'YYYY" years" MM" mons "DD" days "HH24" hours "MI" mins "SS" secs"')
Current Output:
0000 years 00 mons 00 days 464127 hours 07 mins 41 secs
Expected output:
54 years 8 mons 12 days 10 hours 51 mins 12 secs
CodePudding user response:
Use justify_interval()
select justify_interval(make_interval(secs => 1670857661));