# Working with date\_select

**URL:** <https://www.ruby-forum.com/t/working-with-date-select/74484>\
**Category:** Rails\
**Created:** [February 28, 2006, 3:03am UTC](https://www.ruby-forum.com/t/working-with-date-select/74484 "2006-02-28T03:03:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dale](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ecd19e/32.png) [@dale](https://www.ruby-forum.com/u/dale)\
**Post date:** [February 28, 2006, 3:03am UTC](https://www.ruby-forum.com/t/working-with-date-select/74484/1 "2006-02-28T03:03:14Z")

</div>

I am a little confused about the best way to work with date\_select. I  
see that  
in my views it generates a simple input form that allows for the entry  
of year,  
month and date information. If I just leave it at that, great!

But what if now in the controller, I want to work with the date  
information. I  
actually want to take the user input date and compute a new date some  
number of  
days in the future.

How should I use “start\_date(1i), start\_date(2i), start\_date(3i)” in a  
controller to fill in a new SQL date column?

Does there exist helpers to convert from “start\_date(1i),  
start\_date(2i),  
start\_date(3i)” to a Ruby Class like Date or Time?

Page 203 of “Agile Web D. with Rails” implies that SQL Types  
like  
“interval, date” are mapped to the Ruby Class “Date” and the SQL Types  
“datetime, time” are mapped to the Ruby Class “Time”. Why isn’t it that  
date\_select returns a Date object?

Thanks in advance for setting my understanding straight in this matter.

–Dale

---

<div class="post-metadata">

**Author:** ![dale](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ecd19e/32.png) [@dale](https://www.ruby-forum.com/u/dale)\
**Post date:** [February 28, 2006, 9:09pm UTC](https://www.ruby-forum.com/t/working-with-date-select/74484/2 "2006-02-28T21:09:35Z")

</div>

Dale M. wrote:

> Does there exist helpers to convert from “start\_date(1i), start\_date(2i),  
> start\_date(3i)” to a Ruby Class like Date or Time?
> 
> Page 203 of “Agile Web D. with Rails” implies that SQL Types like  
> “interval, date” are mapped to the Ruby Class “Date” and the SQL Types  
> “datetime, time” are mapped to the Ruby Class “Time”. Why isn’t it that  
> date\_select returns a Date object?

If start\_date is an Active Record column of type Date it will be  
automatically set from the three parameters when you call either  
Model.new(params) or model\_instance.update\_attributes(params).

If however start\_date is an attr\_accessor in the model, you’ll have  
to use the select\_date helper instead.

–  
We develop, watch us RoR, in numbers too big to ignore.
