Get last day of the month with Ruby
Thursday, February 8th, 2007last_day_of_the_month = (Date.parse(year_to_process + "-" + (month_to_process.to_i + 1).to_s + "-01") – 1).mday().to_s rescue "31" The final rescue is due to catch the error when month_to_process is 12.