To get all records of MyTable created up until 2 days ago:
MyTable.where(created_at: Date.new..2.days.ago)
Note that you can also look for records with fields containing fields in the future in similar way, i.e. to get all records of MyTable with an event_date at least 2 days from now: