I'm searching for a method to get all the posts of the last month out of my database. They are saved with the publishing date which is formatted as datetime.
I now defined a variable for last months date:
$last_month = date("Y-m-d H:i:s",strtotime("-1 month"));
Now I have to make my SQL Query, which I wrote like this:
SELECT * FROM foo WHERE post_date > STR_TO_DATE($last_month,'%Y-%m-%d %h:%i:%s')
Unfortunately this code leaves me with an Error, saying that I have an error in my syntax - which I don't see. I'm hoping, that anyone of you knows how to solve this little problem. Thans in advance.