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

后端 未结 6 1451
无人及你
无人及你 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:11

    In standard SQL, you want to represent the type as INTERVAL HOUR TO SECOND, but you have a value of type INTERVAL DAY TO SECOND. Can you not use a CAST to get to your required result? In Informix, the notation would be either of:

    SUM(time.endtime - time.starttime)::INTERVAL HOUR(3) TO SECOND
    
    CAST(SUM(time.endtime - time.starttime) AS INTERVAL HOUR(3) TO SECOND)
    

    The former is, AFAIK, Informix-specific notation (or, at least, not standard); the latter is, I believe, SQL standard notation.

提交回复
热议问题