Sql query to select from 1 hour ago?

Use:

DELETE FROM wp_posts
 WHERE post_date < DATE_SUB(NOW(), INTERVAL '1' HOUR)
   AND post_status = 'publish'

Reference:

  • DATE_ADD
  • DATE_SUB

Or even simpler:

SELECT NOW() - INTERVAL 1 HOUR;

So the query becomes:

DELETE FROM wp_posts
 WHERE post_date < NOW() - INTERVAL 1 HOUR
   AND post_status = 'publish'