MySql Date_sub和DATEDIFF不在整数字段中用于时间戳时间()

时间:2017-02-01 12:11:06

标签: mysql sql time datediff

我遇到了MySQL Date_SUB和DATEDIFF()的问题。我用php time()将时间戳写入整数字段。以下查询无效。

tmstmp > NOW() - INTERVAL 1 DAY

OR

tmstmp between (CURDATE() - INTERVAL 1 MONTH ) and CURDATE()

OR

tmstmp > DATE_SUB(CURDATE(), INTERVAL 15 DAY)

错误在哪里?

(我的英语不好)

1 个答案:

答案 0 :(得分:0)

所有这些陈述都运作正常。

set @tmstmp = '2017-01-29';

[in] select @tmstmp > (now() - interval 1 day);
[out] 0
[in] select @tmstmp between (curdate() - interval 1 month ) and curdate();
[out] 1
[in] select @tmstmp > date_sub(curdate(), interval 15 day);
[out] 1