I'm trying to find entries in my table from between 6 months ago and today. Here's the query that I'm currently running:
WHERE (DATE(l.date_fin) BETWEEN DATE(DATE_ADD(NOW(), INTERVAL -6 MONTH)) AND CURDATE())
However, it doesn't look right to me: it feels like there's a more concise and/or faster way to get the same results as this query. Is there any such way?
This should be enough to get what you want:
WHERE l.date_fin > CURRENT_DATE() - INTERVAL 6 MONTH;
How about something like this?
SELECT l.date_fin FROM table WHERE TIMESTAMPDIFF(MONTH,l.date_fin,NOW()) < 6
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With