Topic: searching datetime

Hey all,
I have a model Post with a datetime posted_on attribute.
What's the best way to find all the posts that were posted x days,
let's say 5 days ago from Time.now?

thanx in advance

Pat

Re: searching datetime

found it:

Post.find(:all,:conditions=>['posted_on<?',Time.now-5.days])

Re: searching datetime

You can use 5.days.ago instead of Time.now-5.days. Pretty cool huh? smile

Railscasts - Free Ruby on Rails Screencasts