0

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.

Any ideas?

scrowler
  • 24,273
  • 9
  • 60
  • 92
hookedonwinter
  • 12,436
  • 19
  • 61
  • 74

3 Answers3

1

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'
Matt Dexter
  • 238
  • 2
  • 16
0

Check your column datatype in your table where date column exist

0

Try this i think it will be useful

SELECT * FROM wp_posts WHERE post_date '< 2014-01-01 00:00:00';

शु-Bham
  • 952
  • 1
  • 7
  • 14