A table contains a date field of the format yyyy-mm-dd, I want to grab rows where today is 30 days before that date.
The final script will be run every day as a cron job so needs to pull dates that are exactly 30 days away, but as that will not return any rows today, I have been trying to create a script initially that will pull rows within 30 days.
I have tried alsorts of ways but can't get it to pull the rows.
Here is what I am trying
So for example today is 13th June, I have a row where date_due_to_complete is 20th June so it would fall within 30 days, but the query above returns 0 rows.
Thanks for any help
The final script will be run every day as a cron job so needs to pull dates that are exactly 30 days away, but as that will not return any rows today, I have been trying to create a script initially that will pull rows within 30 days.
I have tried alsorts of ways but can't get it to pull the rows.
Here is what I am trying
Code:
SELECT staff_name, date_due_to_complete FROM mytable WHERE DATEDIFF(NOW(), date_due_to_complete) <= 30 )
So for example today is 13th June, I have a row where date_due_to_complete is 20th June so it would fall within 30 days, but the query above returns 0 rows.
Thanks for any help