MySql difference between two timestamps in days?

前端 未结 7 1199
既然无缘
既然无缘 2020-11-30 01:14

How can I get the difference between two timestamps in days? Should I be using a datetime column for this?


I switched my column to datetime. Simple subtraction doesn\'t
7条回答
  •  广开言路
    2020-11-30 01:35

    If you need the difference in days accounting up to the second:

    SELECT TIMESTAMPDIFF(SECOND,'2010-09-21 21:40:36','2010-10-08 18:23:13')/86400 AS diff
    

    It will return
    diff
    16.8629

提交回复
热议问题