# Date format in Rails 3.0 using sqlite3

**URL:** <https://www.ruby-forum.com/t/date-format-in-rails-3-0-using-sqlite3/186101>\
**Category:** Rails\
**Created:** [March 31, 2010, 4:44pm UTC](https://www.ruby-forum.com/t/date-format-in-rails-3-0-using-sqlite3/186101 "2010-03-31T16:44:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bluecat76](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b5a626/32.png) [@bluecat76](https://www.ruby-forum.com/u/bluecat76)\
**Post date:** [March 31, 2010, 4:44pm UTC](https://www.ruby-forum.com/t/date-format-in-rails-3-0-using-sqlite3/186101/1 "2010-03-31T16:44:15Z")

</div>

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:

`events = CalendarEvent.find :all, :conditions => { :target_date =>
begin_date..end_date }`

which produces following sqlite output:

`SELECT "calendar_events".* FROM "calendar_events" WHERE
("calendar_events"."target_date" BETWEEN 2010-03-29 AND
2010-05-03)`

The result is WRONG, because sqlite treats 2010-03-29 as number of the  
value 1978!

If I write following instead:

`events = CalendarEvent.find :all, :conditions => ["target_date
BETWEEN ? AND ?", begin_date, end_date]`

I get the right result, which is:

`SELECT "calendar_events".* FROM "calendar_events" WHERE
(target_date BETWEEN '2010-03-29' AND '2010-05-02')`

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!
