I have to do some searches with date restrictions such as "this week," "last week", "last month", etc. Is there some clever Rails way of doing this, or do I just have to grind it out? Thanks, -George --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Rails does provide some core extensions for some of what you need. 5.weeks.ago Time.now - 20.minutes Person.created_at - 2.weeks Not sure what else might be available, but that should help you some. On Jun 5, 5:24 pm, George Bailey <listcatc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have to do some searches with date restrictions such as "this > week," "last week", "last month", etc. > Is there some clever Rails way of doing this, or do I just have to > grind it out? > > Thanks, > -George--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Jun 5, 2007, at 3:53 PM, Philip Hallstrom wrote:> Chronic can probably do it... never used it, but it comes up a lot in > responses to questions like this:Thanks Phillip. From the usage examples it looks like it will do the trick. I did a lot of searching before I sent that email, but somehow never came across Chronic. I guess I need to work on my Google skills too. :-) -George --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Jun 5, 2007, at 3:40 PM, Robert Walker wrote:> Rails does provide some core extensions for some of what you need. > > 5.weeks.ago > Time.now - 20.minutes > Person.created_at - 2.weeksYes, i looked at that, but things like "this week" depend on what day it is, so I can''t do a simple subtraction. Phillip Hallstrom pointed out Chronic, which looks like it will solve my problem. Thanks. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> I have to do some searches with date restrictions such as "this > week," "last week", "last month", etc. > Is there some clever Rails way of doing this, or do I just have to > grind it out?Chronic can probably do it... never used it, but it comes up a lot in responses to questions like this: http://chronic.rubyforge.org/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Yeah Chronic will solve it, Chronic.parse(''this week'') will return the Friday of that week, so you can then use that in your search, Chronic.parse(''this month'') picks the middle of the month etc. Used it in a project recently, it''s quite cool. Cam On Jun 6, 7:53 am, George Bailey <listcatc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Jun 5, 2007, at 3:40 PM, Robert Walker wrote: > > > Rails does provide some core extensions for some of what you need. > > > 5.weeks.ago > > Time.now - 20.minutes > > Person.created_at - 2.weeks > > Yes, i looked at that, but things like "this week" depend on what day > it is, so I can''t do a simple subtraction. Phillip Hallstrom pointed > out Chronic, which looks like it will solve my problem. > > Thanks.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---