On 1/29/06, charlie bowman <cbowmanschool / yahoo.com> wrote: > Thanks, I had no idea that it was so simple in Ruby! > > > today = Time.now > puts (today - 7) Careful! If you're using Time, you're subtracting SECONDS: irb(main):001:0> today = Time.now => Mon Jan 30 00:11:51 EST 2006 irb(main):002:0> puts( today - 7 ) Mon Jan 30 00:11:44 EST 2006 => nil That's why I included the " require 'date' " in my example, and suggested that you could use DateTime if you needed times. > > > I thought I would have to write the method myself! > > > > > > > A LeDonne wrote: > > On 1/29/06, Cameron McBride <cameron.mcbride / gmail.com> 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