I tried this and it returned incorrect rows
SELECT `product_id`, `expiry` FROM `products_featured`
WHERE `notified_expiry` = FALSE
AND `expiry` !=
AND DATE_ADD(NOW(), INTERVAL 5 DAY) >= `expiry`
I want to select all rows where the expiry date is within 5 days from now.
The rows returned were
[0]=> array(2) {
["product_id"]=>
string(2) "26"
["expiry"]=>
string(10) "2010-07-07" }
[1]=> array(2) {
["product_id"]=>
string(2) "38"
["expiry"]=>
string(10) "2010-07-24" }
[2]=> array(2) {
["product_id"]=>
string(2) "39"
["expiry"]=>
string(10) "2010-07-07" }
As you can see, only one of those rows is to occur within 5 days (assuming NOW()
is returning 2010-07-22
which I have confirmed).
What am I doing wrong? Thanks.