# Rails, Postgres and the Date Field

**URL:** <https://www.ruby-forum.com/t/rails-postgres-and-the-date-field/94685>\
**Category:** Rails\
**Created:** [May 10, 2006, 10:32pm UTC](https://www.ruby-forum.com/t/rails-postgres-and-the-date-field/94685 "2006-05-10T22:32:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![flopezr333](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/54ee81/32.png) [@flopezr333](https://www.ruby-forum.com/u/flopezr333)\
**Post date:** [May 10, 2006, 10:32pm UTC](https://www.ruby-forum.com/t/rails-postgres-and-the-date-field/94685/1 "2006-05-10T22:32:54Z")

</div>

Hi guys,

I’m having problems with my app. First of all, I created a date\_select  
with the code:

\<%= date\_select(‘contact’, ‘birthday’, :order =\> [‘day’,‘month’,‘year’])  
%\>

In the contacts table, I create a date field:

birthday DATE

When I save the values goes wrong into the database. From the log:

INSERT INTO contacts (“name”, “nickname”, “home\_page”, “mobile”,  
“birthday”, “phone”, “user\_id”, “address”, “email”) VALUES(‘test’,  
‘test’, ‘test’, 12345, ‘0010-01-01’, 12345, 2, ‘test’, ‘removed\_email\_address@domain.invalid’);

I already put the following code in my environment.rb.

ActiveSupport::CoreExtensions::Time::Conversions::DATE\_FORMATS.merge!(  
:default =\> ‘%m/%d/%Y’,  
:date\_time12 =\> “%m/%d/%Y %I:%M%p”,  
:date\_time24 =\> “%m/%d/%Y %H:%M”,  
)

And the date are still displayed as year, month, day.

How can I change this behavior?

Thanks in advance.

Fernando L.

---

<div class="post-metadata">

**Author:** ![flopezr333](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/54ee81/32.png) [@flopezr333](https://www.ruby-forum.com/u/flopezr333)\
**Post date:** [May 10, 2006, 11:03pm UTC](https://www.ruby-forum.com/t/rails-postgres-and-the-date-field/94685/2 "2006-05-10T23:03:47Z")

</div>

Fernando L. wrote:

> birthday DATE  
> The type DATE doesn’t work well with rails. I change the type to  
> timestamp and it worked in the view. Even changing the type of the  
> column, I still have problems recording its values .

Just if I put the date\_select in the format:

\<%= date\_select(‘contact’, ‘birthday’, :order =\> [‘year’,‘month’,‘day’]

It works…

How can I change this to work accordingly with my app?

Thanks,

Fernando L.

---

<div class="post-metadata">

**Author:** ![flopezr333](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/54ee81/32.png) [@flopezr333](https://www.ruby-forum.com/u/flopezr333)\
**Post date:** [May 10, 2006, 11:03pm UTC](https://www.ruby-forum.com/t/rails-postgres-and-the-date-field/94685/3 "2006-05-10T23:03:52Z")

</div>

Fernando L. wrote:

> The type DATE doesn’t work well with rails. I change the type to  
> timestamp and it worked in the view. Even changing the type of the  
> column, I still have problems recording its values .
> 
> Just if I put the date\_select in the format:
> 
> \<%= date\_select(‘contact’, ‘birthday’, :order =\> [‘year’,‘month’,‘day’]
> 
> It DOES NOT works…

Fernando L.
