P
Peter Bailey
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
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
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
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