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!
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to