I'm trying to find a way to do a request in MySQL such as this one :
SELECT * FROM table WHERE insert_date < '14 days'
From googling, I found two answers :
SELECT * FROM table WHERE insert_date < DateAdd(dd,-14,GetDate())
and
SELECT * FROM table WHERE insert_date < DateAdd(day,Datediff(day,0,getdate()),-14)
So here are my questions :
1) Are there better ways to do this ?
2) What is the difference between the two things I found ?
Thanks
Your Google'd answers are for SQL Server, not MySQL.
All of them are getting dates older than 14 days ago, not more recent.
So, I think you want:
SELECT *
FROM table
WHERE insert_date > date_sub(curdate(), interval 14 day);
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