# Re: Calculate last day of month

**URL:** <https://www.ruby-forum.com/t/re-calculate-last-day-of-month/69563>\
**Category:** Ruby\
**Created:** [September 21, 2006, 9:05pm UTC](https://www.ruby-forum.com/t/re-calculate-last-day-of-month/69563 "2006-09-21T21:05:10Z")\
**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, 9:05pm UTC](https://www.ruby-forum.com/t/re-calculate-last-day-of-month/69563/1 "2006-09-21T21:05:10Z")

</div>

> How do I return the date for the last day of this month (September in  
> this example)?

The last day in a month is the day before the first day in the next  
month.

require ‘date’  
d = Date.new( 2006, 10, 1 )  
puts d-1  
#=\> 2006-09-30

---

<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:01pm UTC](https://www.ruby-forum.com/t/re-calculate-last-day-of-month/69563/2 "2006-09-21T22:01:16Z")

</div>

Gavin K. wrote:

> 

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