Re: Calculate last day of month

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

require ‘date’
d = 2006, 10, 1 )
puts d-1
#=> 2006-09-30

Gavin K. wrote:

Slightly nicer is:
puts, 9, -1)

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs