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

后端 未结 6 1493
无人及你
无人及你 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 13:06

    If you wanted postgres to handle the HH:MM:SS formatting for you, take the difference in epoch seconds and convert it to an interval scaled in seconds:

    SELECT SUM(EXTRACT(EPOCH FROM time.endtime) - EXTRACT(EPOCH FROM time.starttime))
             * INTERVAL '1 SECOND' AS hhmmss
    

提交回复
热议问题