Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find all old records returning same amount for greater than and less than (> <)

I'm trying to find (and then delete) all old records in my DB on heroku.

For some reason these two are equal (notice < and >)

Post.find(:all, "updated_at > ?", 30.days.ago).count
Post.find(:all, "updated_at < ?", 30.days.ago).count

Makes me hesitent about using the delete.

What call should I make to ensure I do get only the older records?

like image 681
AdamT Avatar asked Nov 27 '22 07:11

AdamT


1 Answers

The other answers are correct, but for updated ActiveRecord syntax:

Post.where("updated_at < ?", 30.days.ago)
like image 94
Josh Adams Avatar answered Dec 10 '22 05:12

Josh Adams