gregm
1
Hi,
I want to create a named scope that returns all the line where date is
in X number of days.
This is how it looks
named_scope :in, lambda { |number|
{ :conditions => ["event_date = ?", number.days.from_now] }
}
My problem is that is compares the date with the hours, minutes and
seconds and just would to compare the day…
How do I do this?
Greg
gregm
2
On 11 jul, 16:28, Greg Ma [email protected] wrote:
My problem is that is compares the date with the hours, minutes and
seconds and just would to compare the day…
How do I do this?
Greg
Posted viahttp://www.ruby-forum.com/.
I think this would work:
:conditions => [“event_date between ? and ?”,
number.days.from_now.beginning_of_day,
number.days.from_now.end_of_day]
Regards
gregm
3
For MySql this would work
named_scope :in, lambda {|number|
{:conditions => [“date(event_date) = ?”,
number.days.from_now.to_date]}
}
Hope that helps.
Greg