Avg Time difference in mysql

后端 未结 4 1318
被撕碎了的回忆
被撕碎了的回忆 2021-02-12 19:08

Is there a function to find average time difference in the standard time format in my sql.

4条回答
  •  旧巷少年郎
    2021-02-12 19:43

    In order to get actual averages in the standard time format from mysql I had to convert to seconds, average, and then convert back:

    SEC_TO_TIME(AVG(TIME_TO_SEC(TIMEDIFF(timeA, timeB))))
    

    If you don't convert to seconds, you get an odd decimal representation of the minutes that doesn't really make any sense (to me).

提交回复
热议问题