MySql difference between two timestamps in days?

前端 未结 7 1153
既然无缘
既然无缘 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:52

    If you're happy to ignore the time portion in the columns, DATEDIFF() will give you the difference you're looking for in days.

    SELECT DATEDIFF('2010-10-08 18:23:13', '2010-09-21 21:40:36') AS days;
    +------+
    | days |
    +------+
    |   17 |
    +------+
    
    0 讨论(0)
提交回复
热议问题