# Re: Calculate last day of month

**URL:** <https://www.ruby-forum.com/t/re-calculate-last-day-of-month/69572>\
**Category:** Ruby\
**Created:** [September 21, 2006, 10:33pm UTC](https://www.ruby-forum.com/t/re-calculate-last-day-of-month/69572 "2006-09-21T22:33:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![phrogz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@phrogz](https://www.ruby-forum.com/u/phrogz)\
**Post date:** [September 21, 2006, 10:33pm UTC](https://www.ruby-forum.com/t/re-calculate-last-day-of-month/69572/1 "2006-09-21T22:33:21Z")

</div>

From: Norgg [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]

> Slightly nicer is:  
> puts Date.new(2006, 9, -1)  
> #2006-09-30

Well, aren’t you Mr. Tricky? 🙂

Here’s the documentation For Date.civil() describing the feature Norgg  
describes:

"Create a new Date object for the Civil Date specified by year y, month  
m, and day-of-month d.

m and d can be negative, in which case they count backwards from the end  
of the year and the end of the month respectively. No wraparound is  
performed, however, and invalid values cause an ArgumentError to be  
raised."

---

<div class="post-metadata">

**Author:** ![phrogz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@phrogz](https://www.ruby-forum.com/u/phrogz)\
**Post date:** [September 21, 2006, 11:05pm UTC](https://www.ruby-forum.com/t/re-calculate-last-day-of-month/69572/2 "2006-09-21T23:05:29Z")

</div>

On Fri, 22 Sep 2006, Gavin K. wrote:

> "Create a new Date object for the Civil Date specified by year y, month  
> m, and day-of-month d.
> 
> m and d can be negative, in which case they count backwards from the end  
> of the year and the end of the month respectively. No wraparound is  
> performed, however, and invalid values cause an ArgumentError to be  
> raised."

that is damn cool. missed that.

-a
