How to convert an interval like “1 day 01:30:00” into “25:30:00”?

后端 未结 6 1483
无人及你
无人及你 2021-01-01 12:25

I need to add some intervals and use the result in Excel.

Since

sum(time.endtime-time.starttime)

returns the interval as \"1 da

6条回答
  •  天命终不由人
    2021-01-01 12:54

    You could use EXTRACT to convert the interval into seconds.

    SELECT EXTRACT(EPOCH FROM INTERVAL '5 days 3 hours');
    Result: 442800
    

    Then you would need to do your own maths (or let Excel do it).

    Note that '1 day' is not necessarily equivalent to '24 hours' - PostgreSQL handles things like an interval that spans a DST transition.

提交回复
热议问题