From: Daniel Berger Date: 2007-01-23T11:04:25+09:00 Subject: Re: find monday of first week of the month James Edward Gray II wrote: > On Jan 22, 2007, at 4:05 PM, Daniel Berger wrote: > >> require 'date' >> >> date = Date.new(2007, 2) >> p date.strftime("%Y-%m-%d") # 2007-02-01 >> date -= 1 until date.mday == 1 >> p date.strftime("%Y-%m-%d") # 2007-01-29 > > If you start with a Sunday you will end up with a Monday before that. > Not sure that's what was intended. Whoops. date = date.mday == 0 ? date += 1 : date -= 1 until date.mday == 1 Regards, Dan