How can I get the sum of multiple datetime values?

后端 未结 2 433
执笔经年
执笔经年 2020-11-29 12:27

I have a query such that the query\'s result is:

SELECT CONVERT(VARCHAR(8),(MAX(END_TIME)-MIN(START_TIME)),108) as DURATION WHERE ... GROUP BY TITLE
<         


        
2条回答
  •  独厮守ぢ
    2020-11-29 13:05

    You cannot sum times. What you should do instead is use the DateDiff function with your start and end time using the seconds parameter. This will return an integer data type which you can SUM on. When you're done, convert it to a DateTime to format it like hours:minutes:seconds.

提交回复
热议问题