Hi,
I am new to Ruby and Rails, so I don't know if this is my fault, but maybe this is a bug in Rails (I'm using Rails 3.0 beta) which should be reported.
I have following search statement: [code]events = CalendarEvent.find :all, :conditions => { :target_date => begin_date..end_date }[/code]
which produces following sqlite output: [code]SELECT "calendar_events".* FROM "calendar_events" WHERE ("calendar_events"."target_date" BETWEEN 2010-03-29 AND 2010-05-03)[/code]
The result is WRONG, because sqlite treats 2010-03-29 as number of the value 1978!
If I write following instead: [code]events = CalendarEvent.find :all, :conditions => ["target_date BETWEEN ? AND ?", begin_date, end_date][/code]
I get the right result, which is: [code]SELECT "calendar_events".* FROM "calendar_events" WHERE (target_date BETWEEN '2010-03-29' AND '2010-05-02')[/code]
Is there another way to specify the needed format? I already checked, that begin_date and end_date are truly Date values. If I use Date.new(2010,3,29) f.i. the result is exactly the same.
Thanks!