How do I show hours instead of days for an interval in PostgreSQL?

1.2k Views Asked by At

One of my queries is returning the below interval. Istead of showing 6 days, I would like to show 6 x 24 + 19 hours. I would rather not convert to epoch using the extract (epoch from ...) operator. Is there a quick an easy way to do it?

 usage_minus_lost_data_gaps_and_battery_charge 
-----------------------------------------------
 6 days 19:18:21
(1 row)
1

There are 1 best solutions below

2
On BEST ANSWER

Something like this could probably help:

# select to_char('6 days 19:18:21'::interval, 'DD x 24 + HH24 hours');
      to_char       
--------------------
 06 x 24 + 19 hours
(1 row)