# How to make date\_select have a blank option?

**URL:** <https://www.ruby-forum.com/t/how-to-make-date-select-have-a-blank-option/80131>\
**Category:** Rails\
**Created:** [December 21, 2006, 4:51pm UTC](https://www.ruby-forum.com/t/how-to-make-date-select-have-a-blank-option/80131 "2006-12-21T16:51:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![xain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/82dd89/32.png) [@xain](https://www.ruby-forum.com/u/xain)\
**Post date:** [December 21, 2006, 4:51pm UTC](https://www.ruby-forum.com/t/how-to-make-date-select-have-a-blank-option/80131/1 "2006-12-21T16:51:43Z")

</div>

I use date\_select to generate a birthday field.  
I want to make this field optional.  
How can I make date\_select have a blank option?

---

<div class="post-metadata">

**Author:** ![xain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/82dd89/32.png) [@xain](https://www.ruby-forum.com/u/xain)\
**Post date:** [December 21, 2006, 6:12pm UTC](https://www.ruby-forum.com/t/how-to-make-date-select-have-a-blank-option/80131/2 "2006-12-21T18:12:58Z")

</div>

On 21/12/06, Nanyang Z. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I use date\_select to generate a birthday field.  
> I want to make this field optional.  
> How can I make date\_select have a blank option?

From the API docs:

date\_select(“post”, “written\_on”, :start\_year =\> 1995,  
:use\_month\_numbers =\> true,  
:discard\_day =\> true,  
:include\_blank =\> true)

---

<div class="post-metadata">

**Author:** ![xain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/82dd89/32.png) [@xain](https://www.ruby-forum.com/u/xain)\
**Post date:** [December 22, 2006, 8:47am UTC](https://www.ruby-forum.com/t/how-to-make-date-select-have-a-blank-option/80131/3 "2006-12-22T08:47:32Z")

</div>

Jamie Wilson wrote:

> From the API docs:
> 
> date\_select(“post”, “written\_on”, :start\_year =\> 1995,  
> :use\_month\_numbers =\> true,  
> :discard\_day =\> true,  
> :include\_blank =\> true)

It works. thanks.

---

<div class="post-metadata">

**Author:** ![xain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/82dd89/32.png) [@xain](https://www.ruby-forum.com/u/xain)\
**Post date:** [February 15, 2007, 4:09pm UTC](https://www.ruby-forum.com/t/how-to-make-date-select-have-a-blank-option/80131/4 "2007-02-15T16:09:50Z")

</div>

Jamie Wilson wrote:

> On 21/12/06, Nanyang Z. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > I use date\_select to generate a birthday field.  
> > I want to make this field optional.  
> > How can I make date\_select have a blank option?
> 
> From the API docs:
> 
> date\_select(“post”, “written\_on”, :start\_year =\> 1995,  
> :use\_month\_numbers =\> true,  
> :discard\_day =\> true,  
> :include\_blank =\> true)

I use this too, but now when I only select a day, it writes it to the  
database as the 1st of januari of the year (the day I specified). This  
is not good, as it fucks up the system. Any way to solve this?

---

<div class="post-metadata">

**Author:** ![xain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/82dd89/32.png) [@xain](https://www.ruby-forum.com/u/xain)\
**Post date:** [February 15, 2007, 7:50pm UTC](https://www.ruby-forum.com/t/how-to-make-date-select-have-a-blank-option/80131/5 "2007-02-15T19:50:55Z")

</div>

Sorry, but if DHH can proclaim “FUCK YOU” to the world in a Rails  
conference keynote address, I hardly think that we need police the  
casual use of the word on the list. Is there a “no swearing” rule for  
the list somewhere?

b

---

<div class="post-metadata">

**Author:** ![xain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/82dd89/32.png) [@xain](https://www.ruby-forum.com/u/xain)\
**Post date:** [February 15, 2007, 5:50pm UTC](https://www.ruby-forum.com/t/how-to-make-date-select-have-a-blank-option/80131/6 "2007-02-15T17:50:44Z")

</div>

Dax H. wrote:

> I use this too, but now when I only select a day, it writes it to the  
> database as the 1st of januari of the year (the day I specified). This  
> is not good, as it fucks up the system. Any way to solve this?

Can I ask you please to be careful of your language on a public list ?

A.

---

<div class="post-metadata">

**Author:** ![xain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/82dd89/32.png) [@xain](https://www.ruby-forum.com/u/xain)\
**Post date:** [February 16, 2007, 5:46am UTC](https://www.ruby-forum.com/t/how-to-make-date-select-have-a-blank-option/80131/7 "2007-02-16T05:46:49Z")

</div>

It is about courtesy and civility.  
-Larry

On 2/15/07, Ben M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Dax H. wrote:

–  
Best Regards,  
-Larry  
“Work, work, work…there is no satisfactory alternative.”  
— E.Taft Benson
