我的表格中有一个DATETIME列,我想知道DATETIME值与现在之间的天数。
查询必须是这样的:
SELECT *, DATESUBWHATEVER(datetimefield) AS days FROM table
答案 0 :(得分:1)
SELECT TIMESTAMPDIFF(DAY, datetimefield, NOW()) AS days from table;
答案 1 :(得分:0)
您可以使用DATEDIFF()函数
SELECT *, DATEDIFF(DateTimeField,NOW()) FROM TABLE
DATEDIFF参数说明:
DATEDIFF(date1,date2)