From: Mark Hubbart Date: 2005-05-11T00:17:50+09:00 Subject: Re: Enumerating only months in a Date range? On 5/10/05, John Lam wrote: > Is there a straight-forward way to list all of the months in a Date > range? If I construct a date range, the each method iterates by day > only. There isn't a built-in way (that I know of), but it's pretty simple to subclass date to make it work: class MonthlyDate < Date def succ self >> 1 end end class Date def to_monthly m = MonthlyDate.new instance_variables.map do |var| m.instance_variable_set( var,instance_variable_get( var ) ) end m end end Then convert your Dates to MonthlyDates (using #to_monthly) before creating your range. The range will now skip months rather than days. HTH, Mark