Reputation: 165
I need to get a table of product that will expire in the next month.
Should I use this query:
where datediff(expiry_date, now ()) <= 30
Or this query:
expiry_date <= date_add(now(), Interval 1 month)
Upvotes: 0
Views: 48
Reputation: 116
In first query you are taking month days difference .sometime months may be have 28 days ,30 days or 31 days.sometime query may fail or dead lock occur.
Try Second Query ...
expiry_date <= date_add(now(), Interval 1 month)
Upvotes: 2