You can do this with strtotime
$date1 = date("Y-m-d");
$date2 = date("Y-m-d",strtotime("-3 month"));
Then put this dates into BETWEEN
Sql statement like;
WHERE date BETWEEN '.$date1.' AND '.$date2.'
Pregunta
I am developing an PHP and mySQL based Blood Donating application. I want to show those blood donor who are didn't donate blood in last three month from today's date.How can I write the query for show those data..?
No hay solución correcta
Otros consejos
You can do this with strtotime
$date1 = date("Y-m-d");
$date2 = date("Y-m-d",strtotime("-3 month"));
Then put this dates into BETWEEN
Sql statement like;
WHERE date BETWEEN '.$date1.' AND '.$date2.'
you can add query below
SELECT date FROM table WHERE date BETWEEN CURDATE() - INTERVAL 3 MONTH AND CURDATE()
OR you can use the below condition with your query.
SELECT DATE_SUB(NOW(), INTERVAL 3 MONTH;