# Error with datetime\_select w/ Year \<1970 on MS Windows

**URL:** <https://www.ruby-forum.com/t/error-with-datetime-select-w-year-1970-on-ms-windows/110922>\
**Category:** Rails\
**Created:** [August 1, 2007, 2:27am UTC](https://www.ruby-forum.com/t/error-with-datetime-select-w-year-1970-on-ms-windows/110922 "2007-08-01T02:27:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![i\_am\_zigx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/da6949/32.png) [@i\_am\_zigx](https://www.ruby-forum.com/u/i_am_zigx)\
**Post date:** [August 1, 2007, 2:27am UTC](https://www.ruby-forum.com/t/error-with-datetime-select-w-year-1970-on-ms-windows/110922/1 "2007-08-01T02:27:01Z")

</div>

I am seeing something very strange that does not appear to happen on  
OSX.  
Can anyone confirm if this is a valid issue/bug?

I have created a datetime\_select with the following code:  
\<%= datetime\_select(:album, :release\_date, :start\_year =\> 1960) %\>

When i select any year 1970 and above the submit form works fine and i  
can  
debug(:params) no prob… but if i submit 1969 and older, I get the  
following:

ActiveRecord::MultiparameterAssignmentErrors in PublicController#create

1 error(s) on assignment of multiparameter attributes

c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active\_record/base.rb:2094:in  
`execute_callstack_for_multiparameter_attributes' c:/ruby/lib/ruby/gems/1.8/gems/activerecord- 1.15.3/lib/active_record/base.rb:2074:in`assign\_multiparameter\_attributes’  
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active\_record/base.rb:1675:in  
`attributes=' c:/ruby/lib/ruby/gems/1.8/gems/activerecord- 1.15.3/lib/active_record/base.rb:1505:in`initialize\_without\_callbacks’  
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active\_record/callbacks.rb:225:in  
`initialize' #{RAILS_ROOT}/app/controllers/public_controller.rb:39:in`new’  
#{RAILS\_ROOT}/app/controllers/public\_controller.rb:39:in `create’

Request

Parameters: {“commit”=\>“Create”, “album”=\>{“artist”=\>“Jimi Hendrix”,  
“title”=\>“Electric Lady Land”, “release\_date(1i)”=\>“1969”,  
“release\_date(2i)”=\>“12”, “release\_date(3i)”=\>“31”, “genre”=\>“Rock”,  
“release\_date(4i)”=\>“00”, “release\_date(5i)”=\>“00”}}

Here is my version information:

About your application’s environment  
Ruby version 1.8.6 (i386-mswin32)  
RubyGems version 0.9.2  
Rails version 1.2.3  
Active Record version 1.15.3  
Action Pack version 1.13.3  
Action Web Service version 1.2.3  
Action Mailer version 1.3.3  
Active Support version 1.4.2  
Application root C:/railz/music\_library  
Environment development  
Database adapter mysql  
Database schema version 0

Controller Code:

```
def new
    @album = Album.new
    @album.title = 'Electric Lady Land'
end

```

View Code:

```
    <%= start_form_tag(:action => 'create') %>

        Title: <%= text_field(:album, :title) %><br />
        Artist: <%= text_field(:album, :artist) %><br />
        Genre: <%= text_field(:album, :genre) %><br />
        Release Date: <%= datetime_select(:album, :release_date,

```

:start\_year =\> 1960) %\>  
  
  
  
\<%= submit\_tag(“Create”) %\>

```
    <%= end_form_tag %>

```

Thank you all for your time, and my apologies if this is ridiculously  
newbie-ish.

---

<div class="post-metadata">

**Author:** ![i\_am\_zigx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/da6949/32.png) [@i\_am\_zigx](https://www.ruby-forum.com/u/i_am_zigx)\
**Post date:** [August 1, 2007, 9:42pm UTC](https://www.ruby-forum.com/t/error-with-datetime-select-w-year-1970-on-ms-windows/110922/2 "2007-08-01T21:42:21Z")

</div>

If anyone knows a starting point for investigating this iw ould be  
happy to follow up on my own, but i’m not sure where to start. thank  
you

---

<div class="post-metadata">

**Author:** ![i\_am\_zigx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/da6949/32.png) [@i\_am\_zigx](https://www.ruby-forum.com/u/i_am_zigx)\
**Post date:** [August 2, 2007, 12:52am UTC](https://www.ruby-forum.com/t/error-with-datetime-select-w-year-1970-on-ms-windows/110922/3 "2007-08-02T00:52:36Z")

</div>

On Aug 1, 2007, at 3:41 PM, removed\_email\_address@domain.invalid wrote:

> > \<%= datetime\_select(:album, :release\_date, :start\_year =\> 1960) %\>
> > 
> > When i select any year 1970 and above the submit form works fine  
> > and i can  
> > debug(:params) no prob… but if i submit 1969 and older, I get the  
> > following:

Time only works for dates that are not prior to 1970-01-01 00:00:00  
UTC when stored as a number of seconds since that time (often  
referred to as the epoch).

Use a Date rather than a Time and you should be OK.

-Rob

Rob B. [http://agileconsultingllc.com](http://agileconsultingllc.com)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![i\_am\_zigx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/da6949/32.png) [@i\_am\_zigx](https://www.ruby-forum.com/u/i_am_zigx)\
**Post date:** [August 2, 2007, 1:12am UTC](https://www.ruby-forum.com/t/error-with-datetime-select-w-year-1970-on-ms-windows/110922/4 "2007-08-02T01:12:37Z")

</div>

It appears that you are working through my training tutorial on  
[Lynda.com](http://Lynda.com) so I should jump in to help… 🙂

Some platforms don’t handle dates outside the 1970-2038 range well.  
Rails’ has to convert HTML form parameters into something that your  
database can store. The SQL adapter in Rails uses the Time class to  
do that (because it’s faster) but can be told to use DateTime instead.  
On most systems, it’s either not a problem or has been sorted out, but  
there are a few set ups that still cause people grief. (such as  
Microsoft / MS SQL)

There are official patches in the works such as:  
[http://dev.rubyonrails.org/ticket/3430](http://dev.rubyonrails.org/ticket/3430)  
and also do-it-yourself work arounds (a Google search for  
‘ActiveRecord DateTime 1970’ should find them). Searches in this  
forum for ‘1970’ may also yield useful tips.

My suggestion would be to input more recent dates while you continue  
the tutorial. It’s not important for you to solve this problem in  
order to learn the essentials of Rails. When you actually need dates  
before 1970 for an application, you can try and see if it’s been  
solved “officially”, switch platforms then, or investigate the DIY  
solutions out there.

HTH,  
Kevin S.
