I need to add some intervals and use the result in Excel.
Since
sum(time.endtime-time.starttime)
returns the interval as "1 day 01:30:00" and this format breaks my Excel sheet, I thought it'd be nice to have the output like "25:30:00" but found no way to do it in the PostgreSQL documentation.
Can anyone here help me out?
Since there is not an exact solution for the topic:
=> SELECT date_part('epoch', INTERVAL '1 day 01:30:00') * INTERVAL '1 second' hours; hours ----------- 25:30:00 (1 row)
Source: Documentation
The only thing I can come with (beside parsing the number of days and adding 24 to the hours every time) is :
mat=> select date_part('epoch', '01 day 1:30:00'::interval); date_part ----------- 91800 (1 row)
It will give you the number of seconds, which may be ok for excel.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With