From: Robert Dober Date: 2007-09-26T22:57:46+09:00 Subject: Re: Finding the last Sunday of a month On 9/26/07, Peter Bailey wrote: > Hello, > I need to find the date for the last Sunday in January, for any year. I > need this for a budgetary script I'm trying to write. Using the > Date/Time module, I've done this so far. > > require 'date' > now = DateTime.now > year = now.year > d = Date.new(now.year, 1, 31) > puts d.wday > Hmm I believe that d = Date.new( now.year, 1, 31 ) d - d.wday should do the trick HTH Robert > yields: 3 > > This tells me that the last day of January is a Wednesday. But, I need > that last Sunday. Is there a method in 'date' that can give me the date > of the last Sunday? The last Sundays of each month are the boundaries > for my company's budget periods. > > Thanks, > Peter > -- > Posted via http://www.ruby-forum.com/. > > -- I'm an atheist and that's it. I believe there's nothing we can know except that we should be kind to each other and do what we can for other people. -- Katharine Hepburn