# Why am I onlu limited by the years from 2005-2015?

**URL:** <https://www.ruby-forum.com/t/why-am-i-onlu-limited-by-the-years-from-2005-2015/190569>\
**Category:** Rails\
**Created:** [June 22, 2010, 11:36pm UTC](https://www.ruby-forum.com/t/why-am-i-onlu-limited-by-the-years-from-2005-2015/190569 "2010-06-22T23:36:14Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![swengineer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/97f17d/32.png) [@swengineer](https://www.ruby-forum.com/u/swengineer)\
**Post date:** [June 22, 2010, 11:36pm UTC](https://www.ruby-forum.com/t/why-am-i-onlu-limited-by-the-years-from-2005-2015/190569/1 "2010-06-22T23:36:14Z")

</div>

I have created a scaffold, part of which was dob:date

When I view my web page under DOB, I have only the years listed from  
2005-2015. What should I do to enter older years?

Thanks.

---

<div class="post-metadata">

**Author:** ![swengineer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/97f17d/32.png) [@swengineer](https://www.ruby-forum.com/u/swengineer)\
**Post date:** [June 22, 2010, 11:47pm UTC](https://www.ruby-forum.com/t/why-am-i-onlu-limited-by-the-years-from-2005-2015/190569/2 "2010-06-22T23:47:29Z")

</div>

> I have created a scaffold, part of which was dob:date
> 
> When I view my web page under DOB, I have only the years listed from  
> 2005-2015. What should I do to enter older years?

See the docs for date\_select (even if it’s a datetime\_select the same  
options work). Specifically:

:start\_year - Set the start year for the year select. Default is  
Time.now.year - 5.  
:end\_year - Set the end year for the year select. Default is  
Time.now.year + 5.

---

<div class="post-metadata">

**Author:** ![swengineer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/97f17d/32.png) [@swengineer](https://www.ruby-forum.com/u/swengineer)\
**Post date:** [June 22, 2010, 11:56pm UTC](https://www.ruby-forum.com/t/why-am-i-onlu-limited-by-the-years-from-2005-2015/190569/3 "2010-06-22T23:56:40Z")

</div>

Philip H. wrote:

> > I have created a scaffold, part of which was dob:date
> > 
> > When I view my web page under DOB, I have only the years listed from  
> > 2005-2015. What should I do to enter older years?
> 
> See the docs for date\_select (even if it’s a datetime\_select the same  
> options work). Specifically:
> 
> :start\_year - Set the start year for the year select. Default is  
> Time.now.year - 5.  
> :end\_year - Set the end year for the year select. Default is  
> Time.now.year + 5.

Thanks Philip.

I’m actually new to RoR. Where can I make this change?

Thanks.

---

<div class="post-metadata">

**Author:** ![swengineer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/97f17d/32.png) [@swengineer](https://www.ruby-forum.com/u/swengineer)\
**Post date:** [June 23, 2010, 12:10am UTC](https://www.ruby-forum.com/t/why-am-i-onlu-limited-by-the-years-from-2005-2015/190569/4 "2010-06-23T00:10:18Z")

</div>

Philip H. wrote:

> On Jun 22, 2010, at 2:56 PM, Abder-rahman Ali wrote:
> 
> > > Time.now.year - 5.  
> > > :end\_year - Set the end year for the year select. Default is  
> > > Time.now.year + 5.
> > 
> > Thanks Philip.
> > 
> > I’m actually new to RoR. Where can I make this change?
> 
> In the view file. Find the file that has the form and then look for  
> date\_select and add the options…

If you mean the “views” folder, there is nothing actually on it. Just  
\*.html.erb

---

<div class="post-metadata">

**Author:** ![swengineer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/97f17d/32.png) [@swengineer](https://www.ruby-forum.com/u/swengineer)\
**Post date:** [June 23, 2010, 12:00am UTC](https://www.ruby-forum.com/t/why-am-i-onlu-limited-by-the-years-from-2005-2015/190569/5 "2010-06-23T00:00:57Z")

</div>

On Jun 22, 2010, at 2:56 PM, Abder-rahman Ali wrote:

> > Time.now.year - 5.  
> > :end\_year - Set the end year for the year select. Default is  
> > Time.now.year + 5.
> 
> Thanks Philip.
> 
> I’m actually new to RoR. Where can I make this change?

In the view file. Find the file that has the form and then look for  
date\_select and add the options…

---

<div class="post-metadata">

**Author:** ![swengineer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/97f17d/32.png) [@swengineer](https://www.ruby-forum.com/u/swengineer)\
**Post date:** [June 23, 2010, 12:26am UTC](https://www.ruby-forum.com/t/why-am-i-onlu-limited-by-the-years-from-2005-2015/190569/6 "2010-06-23T00:26:43Z")

</div>

On Jun 22, 2010, at 3:10 PM, Abder-rahman Ali wrote:

> > In the view file. Find the file that has the form and then look for  
> > date\_select and add the options…
> 
> If you mean the “views” folder, there is nothing actually on it. Just  
> \*.html.erb

Right. And one of those .html.erb files will have the field you want…

---

<div class="post-metadata">

**Author:** ![swengineer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/97f17d/32.png) [@swengineer](https://www.ruby-forum.com/u/swengineer)\
**Post date:** [June 23, 2010, 2:50am UTC](https://www.ruby-forum.com/t/why-am-i-onlu-limited-by-the-years-from-2005-2015/190569/7 "2010-06-23T02:50:18Z")

</div>

Philip H. wrote:

> On Jun 22, 2010, at 3:10 PM, Abder-rahman Ali wrote:
> 
> > > In the view file. Find the file that has the form and then look for  
> > > date\_select and add the options…
> > 
> > If you mean the “views” folder, there is nothing actually on it. Just  
> > \*.html.erb
> 
> Right. And one of those .html.erb files will have the field you want…

I found the date\_select, but got the following error. Any ideas?

compile error  
/Users/abder/Desktop/RoR  
projects/student\_info/app/views/students/new.html.erb:16: syntax error,  
unexpected ‘:’, expecting ‘)’  
…year=\>1950, :end\_year=\>2010) :dob ).to\_s); @output\_buffer.co…

Extracted source (around line #16):

13:

  
14: 

15: \<%= f.label :dob %\>  
  
16: \<%= f.date\_select(:start\_year=\>1950, :end\_year=\>2010) :dob %\>  
17:

  
18: 

19: \<%= f.label :major %\>

Thanks.

---

<div class="post-metadata">

**Author:** ![swengineer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/97f17d/32.png) [@swengineer](https://www.ruby-forum.com/u/swengineer)\
**Post date:** [June 23, 2010, 11:23am UTC](https://www.ruby-forum.com/t/why-am-i-onlu-limited-by-the-years-from-2005-2015/190569/8 "2010-06-23T11:23:49Z")

</div>

botp wrote:

> On Wed, Jun 23, 2010 at 8:50 AM, Abder-rahman Ali [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > 16: ï¿½ ï¿½ \<%= f.date\_select(:start\_year=\>1950, :end\_year=\>2010) :dob %\>
> 
> you’ll need the object and method,
> 
> [ActionView::Helpers::DateHelper](http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#M002264)
> 
> kind regards -botp

Thanks a lot botp.

Yes, I wasn’t aware of the correct syntax.

---

<div class="post-metadata">

**Author:** ![swengineer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/97f17d/32.png) [@swengineer](https://www.ruby-forum.com/u/swengineer)\
**Post date:** [June 23, 2010, 4:56am UTC](https://www.ruby-forum.com/t/why-am-i-onlu-limited-by-the-years-from-2005-2015/190569/9 "2010-06-23T04:56:33Z")

</div>

On Wed, Jun 23, 2010 at 8:50 AM, Abder-rahman Ali [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> 16: \<%= f.date\_select(:start\_year=\>1950, :end\_year=\>2010) :dob %\>

you’ll need the object and method,

> **[ActionView::Helpers::DateHelper](https://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#M002264)**
>
> Action View Date Helpers The Date Helper primarily creates select/option tags for different kinds of dates and times or date and time elements.

kind regards -botp
