MySQL WHERE statement for finding expiry date within 2 days
I have a column named ex开发者_开发知识库piry which holds the expiry date of the item in timestamp format.
How would I execute a MySQL query to only select items with an expiry date within 2 days?
Thanks!!
SELECT * FROM table WHERE expiry BETWEEN(TODAY(), TODAY() + 2)
SELECT * FROM table WHERE DATEDIFF(expire, NOW()) <= 2;
select * from mytable
where expiry between now() and adddate(now(), INTERVAL 2 DAY);
SELECT ...
WHERE expiry <= NOW()+"2 days";
WHERE dateCol <= date_sub(now(), interval 2 day);
精彩评论