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?

thanx in advance

Pat

recent_posts = Post.find(:all,
:conditions => “date_posted >
#{5.days.ago.to_s(:db)}”)

oops…

recent_posts = Post.find(:all, :conditions => “posted_on >
#{5.days.ago.to_s(:db)}”)

jdswift wrote:

recent_posts = Post.find(:all, :conditions => “posted_on >
#{5.days.ago.to_s(:db)}”)

Don’t you need more quotes?

Which of these would work?

:conditions => [‘posted_on > ?’, 5.days.ago.to_s(:db)]

:conditions => [‘posted_on > ?’, 5.days.ago]


Phlip
Redirecting... ← NOT a blog!!!