I'm using the following raw Postgres SQL in my where() call to find records where some_date is two days from now:
SomeModel.where('date(some_date) - date(NOW()) = 2')
Can it be written using pure ActiveRecord syntax without raw SQL?
This should work, haven't tested it though.
SomeModel.where('date(some_date) = ?', 2.days.ago.to_date)
#or
SomeModel.where('some_date::date = ?', 2.days.ago.to_date)
If you want it to be any purer, without the date sql function, I'm not seeing it, at least not without creating a db view.