Hi, Could anybody please help me to search the record by date I have one products table. In that table I have created_at.I want to search the records by date. I mean, if i select month as january and year as 2006 then i want to get the list as per that month only. Ex: Created At Product Price 2006-09-18 Ruby 4.5 2006-09-18 Ruby 4.5 2006-08-18 Ruby 4.5 2006-08-04 shq 8.0 If i select September then I should be able to see Created At Product Price 2006-09-18 Ruby 4.5 2006-09-18 Ruby 4.5 So how to do that code?? please help me regarding this.. Thanks in advance Harish -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
For the ruby side you can locate the month using the month() method on your date variable. For the SQL side look in the reference for BETWEEN. It''s commonly associated with date range searching. Naga harish Kanegolla wrote:> Hi, > Could anybody please help me to search the record by date > > I have one products table. In that table I have created_at.I want to > search the records by date. > > I mean, if i select month as january and year as 2006 then i want to get > the list as per that month only. > Ex: > Created At Product Price > 2006-09-18 Ruby 4.5 > 2006-09-18 Ruby 4.5 > 2006-08-18 Ruby 4.5 > 2006-08-04 shq 8.0 > > If i select September then I should be able to see > > Created At Product Price > 2006-09-18 Ruby 4.5 > 2006-09-18 Ruby 4.5 > > So how to do that code?? please help me regarding this.. > > Thanks in advance > Harish > > -- > Posted via http://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
And/or, see if your db supplies a way to extract a month from a date, then select on that. For example, you could do something like the following in mySql. def whatever(month) @products = Product.find(:all, :conditions => [''month(created_on) ?'', month] end You get the idea. On 9/18/06, Brittain <britta1362-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > For the ruby side you can locate the month using the month() method on > your date variable. For the SQL side look in the reference for > BETWEEN. It''s commonly associated with date range searching. > > > Naga harish Kanegolla wrote: > > Hi, > > Could anybody please help me to search the record by date > > > > I have one products table. In that table I have created_at.I want to > > search the records by date. > > > > I mean, if i select month as january and year as 2006 then i want to get > > the list as per that month only. > > Ex: > > Created At Product Price > > 2006-09-18 Ruby 4.5 > > 2006-09-18 Ruby 4.5 > > 2006-08-18 Ruby 4.5 > > 2006-08-04 shq 8.0 > > > > If i select September then I should be able to see > > > > Created At Product Price > > 2006-09-18 Ruby 4.5 > > 2006-09-18 Ruby 4.5 > > > > So how to do that code?? please help me regarding this.. > > > > Thanks in advance > > Harish > > > > -- > > Posted via http://www.ruby-forum.com/. > > > > >-- The best way to implement code quickly is to implement less of it. (http://www.xprogramming.com/Practices/PracNotNeed.html) -- Ron Jeffries --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi, I tries like this. Its giving error. "stack level too deep". wat is meant by this error?? could u please help? Harish Michael Campbell wrote:> And/or, see if your db supplies a way to extract a month from a date, > then select on that. > > For example, you could do something like the following in mySql. > > def whatever(month) > @products = Product.find(:all, :conditions => [''month(created_on) > ?'', month] > end > > You get the idea. > > On 9/18/06, Brittain <britta1362-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> > I have one products table. In that table I have created_at.I want to >> > >> > >> > -- >> > Posted via http://www.ruby-forum.com/. >> >> >> > >> > > > -- > The best way to implement code quickly is to implement less of it. > (http://www.xprogramming.com/Practices/PracNotNeed.html) -- Ron > Jeffries-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 9/19/06, Naga harish Kanegolla <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hi, > I tries like this. Its giving error. "stack level too deep". wat is > meant by this error?? could u please help? > > Harish > > Michael Campbell wrote: > > And/or, see if your db supplies a way to extract a month from a date, > > then select on that. > > > > For example, you could do something like the following in mySql. > > > > def whatever(month) > > @products = Product.find(:all, :conditions => [''month(created_on) > > ?'', month] > > endOften that means you have a recursive infinite loop somewhere. I''d have to see the exact code though. -- A wise man once told me it is not wise to quote what a wise man once told you. -- Unknown --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---