How can I make an average of dates in MySQL?

前端 未结 7 2099
感情败类
感情败类 2020-12-01 20:42

How can I make an average between dates in MySQL? I am more interested in the time values, hours and minutes.

On a table with:

| date_one   | datetime          


        
相关标签:
7条回答
  • 2020-12-01 21:37
    SELECT date_one + (date_two - date_one) / 2 AS average_date
    FROM thetable
    WHERE whatever
    

    You can't sum dates, but you can subtract them and get a time interval that you can halve and add back to the first date.

    0 讨论(0)
提交回复
热议问题