Find by compared date

I how to find an object by an exact relative date, such as:

Model.find(:date => 2.days.ago)

How do I find an object with a :date of at least two days ago or at most
two days ago?

Peter M. wrote:

I how to find an object by an exact relative date, such as:

Model.find(:date => 2.days.ago)

How do I find an object with a :date of at least two days ago or at most
two days ago?

Model.find(:conditions => [‘date >= ?’, 2.days.ago])

Keynan P. wrote:

Model.find(:conditions => [‘date >= ?’, 2.days.ago])

Thanks for your response Kenyan. I got this code to work for the find
method:

Model.find(:first, :conditions => [‘date <= ?’, 2.days.ago])

Any idea how I might get this to work with the ‘.exists?’ method?

Thanks Again,

Peter

This is what i will use for the exist method:

Model.exists?([“date <= ?”,2.days.ago])

Thanks Again,

Peter

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs