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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
recent_posts = Post.find(:all,
:conditions => "date_posted >
#{5.days.ago.to_s(:db)}")
On Nov 30, 11:02 am, "Patrick Aljord"
<patc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> 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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
oops...
recent_posts = Post.find(:all, :conditions => "posted_on >
#{5.days.ago.to_s(:db)}")
On Nov 30, 11:02 am, "Patrick Aljord"
<patc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> 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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
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 http://www.greencheese.us/ZeekLand <-- NOT a blog!!! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---