Avg Time difference in mysql

后端 未结 4 2214
清歌不尽
清歌不尽 2021-02-12 19:04

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

4条回答
  •  不思量自难忘°
    2021-02-12 19:22

    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).

提交回复
热议问题