From: Ezra Zygmuntowicz Date: 2006-01-30T15:59:48+09:00 Subject: Re: relative dates On Jan 29, 2006, at 8:28 PM, A LeDonne wrote: > On 1/29/06, Cameron McBride wrote: >>> how can I do this? "last_week = 7.days.ago" In rails you are already done: >> require_gem 'actionpack' => true >> last_week = 7.days.ago => Sun Jan 22 22:59:26 PST 2006 >> p last_week Sun Jan 22 22:59:26 PST 2006 -Ezra >> >> 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 > -Ezra Zygmuntowicz WebMaster Yakima Herald-Republic Newspaper http://yakimaherald.com ezra@yakima-herald.com blog: http://brainspl.at