Greater than (>) not working in mysql query
I'm trying to run a query on my WordPress database to get a list of all posts and some other data from a certain month. I'm running into an issue with post_date, where looking for posts before a certain date works fine, but looking for posts after a certain date returns 0 results.
This example returns 0 results:
SELECT * FROM `wp_posts` WHERE `post_date` > '2014-01-01 00:00:00';
However this returns a ton of results:
SELECT * FROM `wp_posts` WHERE `post_date` < '2014-01-01 00:00:00';
There are posts published after 2014-01-01, so that's not the problem.
Check your column datatype in your table where date column exist
Try casting that field as a date if all you want to evaluate is the date:
SELECT * FROM wp_posts WHERE CAST(post_date AS DATE) > '2014-01-01'
Try this i think it will be useful
SELECT * FROM wp_posts WHERE post_date '< 2014-01-01 00:00:00';