# Rails 2.1: invalid date automatically convertion

**URL:** <https://www.ruby-forum.com/t/rails-2-1-invalid-date-automatically-convertion/140384>\
**Category:** Rails\
**Created:** [June 13, 2008, 1:00pm UTC](https://www.ruby-forum.com/t/rails-2-1-invalid-date-automatically-convertion/140384 "2008-06-13T13:00:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![makoto\_kuwata](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a4c791/32.png) [@makoto\_kuwata](https://www.ruby-forum.com/u/makoto_kuwata)\
**Post date:** [June 13, 2008, 1:00pm UTC](https://www.ruby-forum.com/t/rails-2-1-invalid-date-automatically-convertion/140384/1 "2008-06-13T13:00:59Z")

</div>

Hi all,

Rails 2.1 seems to converts the following parameters  
{‘birth(1i)’=‘1990’, ‘birth(2i)’=\>‘2’, ‘birth(3i)’=\>‘31’}  
into date ‘1990-03-02’ automatically.  
Is it able to inhibit this convertion?

–  
makoto kuata

---

<div class="post-metadata">

**Author:** ![makoto\_kuwata](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a4c791/32.png) [@makoto\_kuwata](https://www.ruby-forum.com/u/makoto_kuwata)\
**Post date:** [June 16, 2008, 8:50am UTC](https://www.ruby-forum.com/t/rails-2-1-invalid-date-automatically-convertion/140384/2 "2008-06-16T08:50:28Z")

</div>

Does anyone help me?  
The following is an example to be converted invalid  
date automatically (2008-02-31 -\> 2008-03-02).  
I want to stop this convertion.

$ ruby script/generate scaffold person name:string birth:date  
$ rake db:migrate  
$ ruby script/console

> > hash = {“name”=\>“Foo”, “birth(1i)”=\>“2008”, “birth(2i)”=\>“2”, “birth(3i)”=\>“31”}  
> > person = Person.new(hash)  
> > p person  
> > #\<Person id: nil, name: “Foo”, birth: “2008-03-02”, created\_at: nil,  
> > updated\_at: nil\>

–  
makoto kuwata

---

<div class="post-metadata">

**Author:** ![makoto\_kuwata](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a4c791/32.png) [@makoto\_kuwata](https://www.ruby-forum.com/u/makoto_kuwata)\
**Post date:** [October 31, 2008, 6:48pm UTC](https://www.ruby-forum.com/t/rails-2-1-invalid-date-automatically-convertion/140384/3 "2008-10-31T18:48:41Z")

</div>

makoto kuwata wrote:

> Does anyone help me?  
> The following is an example to be converted invalid  
> date automatically (2008-02-31 -\> 2008-03-02).  
> I want to stop this convertion.
> 
> $ ruby script/generate scaffold person name:string birth:date  
> $ rake db:migrate  
> $ ruby script/console
> 
> > > hash = {“name”=\>“Foo”, “birth(1i)”=\>“2008”, “birth(2i)”=\>“2”, “birth(3i)”=\>“31”}  
> > > person = Person.new(hash)  
> > > p person  
> > > #\<Person id: nil, name: “Foo”, birth: “2008-03-02”, created\_at: nil,  
> > > updated\_at: nil\>
> 
> –  
> makoto kuwata

There is no February 31, 2008 (2008-02-31). This year, 2008, is a leap  
year so there WAS a February 29, 2008. The next day would be March 1,  
2008 (February 30, 2008 by your calendar) and the day after March 2,  
2008 (2008-03-02) or February 31, 2008 on your calendar. So Rails/Ruby  
“fixed” it for you. If you don’t want that behaviour, use strings for  
you special two extra days in February. (What are you gong to do next  
year without February 29, 2009? 🙂

CEO Summary:  
ROR got your back!
