# Get month number of a date

**URL:** <https://www.ruby-forum.com/t/get-month-number-of-a-date/97419>\
**Category:** Rails\
**Created:** [July 6, 2006, 11:51pm UTC](https://www.ruby-forum.com/t/get-month-number-of-a-date/97419 "2006-07-06T23:51:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sail](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/5fc32e/32.png) [@sail](https://www.ruby-forum.com/u/sail)\
**Post date:** [July 6, 2006, 11:51pm UTC](https://www.ruby-forum.com/t/get-month-number-of-a-date/97419/1 "2006-07-06T23:51:18Z")

</div>

how can i get the month number of a specific.

for example this code donÂ´t work

month(Date.today)

---

<div class="post-metadata">

**Author:** ![sail](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/5fc32e/32.png) [@sail](https://www.ruby-forum.com/u/sail)\
**Post date:** [July 6, 2006, 11:58pm UTC](https://www.ruby-forum.com/t/get-month-number-of-a-date/97419/2 "2006-07-06T23:58:35Z")

</div>

On Jul 6, 2006, at 5:51 PM, sail wrote:

> how can i get the month number of a specific.
> 
> for example this code don´t work
> 
> month(Date.today)

> > Time.now.month  
> > =\> 7

---

<div class="post-metadata">

**Author:** ![sail](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/5fc32e/32.png) [@sail](https://www.ruby-forum.com/u/sail)\
**Post date:** [July 7, 2006, 12:01am UTC](https://www.ruby-forum.com/t/get-month-number-of-a-date/97419/3 "2006-07-07T00:01:51Z")

</div>

On 7/6/06, sail [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> how can i get the month number of a specific.
> 
> for example this code donÂ´t work
> 
> month(Date.today)

Date.today.month

For more info:

[http://www.ruby-doc.org/core/classes/Date.html](http://www.ruby-doc.org/core/classes/Date.html)

Tom

---

<div class="post-metadata">

**Author:** ![sail](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/5fc32e/32.png) [@sail](https://www.ruby-forum.com/u/sail)\
**Post date:** [July 7, 2006, 12:51am UTC](https://www.ruby-forum.com/t/get-month-number-of-a-date/97419/4 "2006-07-07T00:51:44Z")

</div>

On Jul 6, 2006, at 6:09 PM, sail wrote:

> for example in visualbasic today is  
> cdbl(date) = 38904

Assuming that the “value double of a date” is like the number of days  
since some date in the past, you could do:

> > require ‘date’  
> > =\> true
> 
> > Date.today.jd - 38904  
> > =\> 2415019
> 
> > class Date  
> > def cdbl(start=2415019)  
> > self.jd - start  
> > end  
> > end  
> > =\> nil
> 
> > Date.today.cdbl  
> > =\> 38904

Then tomorrow will be:

> > Date.today.succ.cdbl  
> > =\> 38905

I suppose that’s what you’re asking, but perhaps you need to step  
back and think about what you are really trying to accomplish. (And  
if a direct translation from visualbasic is the right thing to do.)

-Rob

---

<div class="post-metadata">

**Author:** ![sail](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/5fc32e/32.png) [@sail](https://www.ruby-forum.com/u/sail)\
**Post date:** [July 7, 2006, 12:09am UTC](https://www.ruby-forum.com/t/get-month-number-of-a-date/97419/5 "2006-07-07T00:09:08Z")

</div>

tanks

Tom W. & Rob B.

that works very well.

but i have a new question more complex for you…

how can i get the value double of a date.

for example in visualbasic today is  
cdbl(date) = 38904
