From: Yossef Mendelssohn Date: 2010-02-10T03:58:28+09:00 Subject: Re: algorithm to truncate date to beginning of week? On Feb 9, 12:32 pm, Chuck Remes wrote: > My end goal is to always be able to pick the first Sunday at midnight backwards from a given date. If there is another approach to accomplish this, please share. Use the logic inherent in Date objects. They can tell you the weekday (as an integer, 0-based starting at Sunday), and subtraction/addition work on days. $ irb -rdate >> d = Date.today => # >> d.to_s => "2010-02-09" >> d-d.wday => # >> _.to_s => "2010-02-07" A Date object is just that, a date. If you mean a time, you can recreate the date using parts of the time. >> t = Time.now => Tue Feb 09 12:54:48 -0600 2010 >> d = Date.new(t.year, t.month, t.day) => # >> d.to_s => "2010-02-09" Or if you still need a Time object when you're done, you can go the other way as well. >> t = Time.local(d.year, d.month, d.day) => Tue Feb 09 00:00:00 -0600 2010 HTH HAND -- -yossef