From: charlie bowman Date: 2006-01-30T13:56:07+09:00 Subject: Re: relative dates Thanks, I had no idea that it was so simple in Ruby! today = Time.now puts (today - 7) I thought I would have to write the method myself! A LeDonne wrote: > On 1/29/06, Cameron McBride wrote: >> > how can I do this? "last_week = 7.days.ago" >> >> or subtract in seconds: >> last_week = today - 7*24*60*60 >> >> Cameron >> > > This is probably going to be easier with Date than with Time... > > irb(main):001:0> require 'date' > => true > irb(main):002:0> now = Date.today; now.strftime() > => "2006-01-29" > irb(main):003:0> last_week = now - 7; last_week.strftime() > => "2006-01-22" > > If you are concerned about times, you can use DateTime in place of Date > above. > > -A -- Posted via http://www.ruby-forum.com/.