I am very new to ruby on rails programming, I am using the oracle as my database, In my project there r 2 text box fields and in first and second text boxes i want the date field to be enter by the client and want to display the record between those 2 dates how can i do the same, plz be more specific Thanks in advance, Vaibhavi... Not so good not so bad -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
You can do this very easily with a named scope in your model: named_scope :between, lambda {|start_date, end_date| {:conditions => ["created_at BETWEEN :start AND :end", {:start => start_date, :end => end_date}]}} On Apr 8, 5:51 pm, Vaibhav Deshpande <rails-mailing-l...@andreas- s.net> wrote:> I am very new to ruby on rails programming, > I am using the oracle as my database, > > In my project there r 2 text box fields and in first and second text > boxes i want the date field to be enter by the client and want to > display the record between those 2 dates how can i do the same, plz be > more specific > > Thanks in advance, > Vaibhavi... > > Not so good not so bad > -- > Posted viahttp://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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Vaibhav Deshpande wrote:> I am very new to ruby on rails programming, > I am using the oracle as my database, > > In my project there r 2 text box fields and in first and second text > boxes i want the date field to be enter by the client and want to > display the record between those 2 dates how can i do the same, plz be > more specificI''m not sure if this is an issue or not, but note that Oracle''s DATE field is also used for storing DATETIME. Maybe the Rails Oracle adaptor handles this properly, but I just wanted to mention it in case you see weird behavior.> I am using the oracle as my database,P. S. I wish my application could use "The Oracle" as its database. It would always get the correct response even if it doesn''t know what to ask. ;-) http://www.imdb.com/character/ch0000765/ -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
Robert Walker wrote:> Vaibhav Deshpande wrote: >> I am very new to ruby on rails programming, >> I am using the oracle as my database, >> >> In my project there r 2 text box fields and in first and second text >> boxes i want the date field to be enter by the client and want to >> display the record between those 2 dates how can i do the same, plz be >> more specific > > I''m not sure if this is an issue or not, but note that Oracle''s DATE > field is also used for storing DATETIME. Maybe the Rails Oracle adaptor > handles this properly, but I just wanted to mention it in case you see > weird behavior. > >> I am using the oracle as my database, > > P. S. I wish my application could use "The Oracle" as its database. It > would always get the correct response even if it doesn''t know what to > ask. ;-) > > http://www.imdb.com/character/ch0000765/I used @date2ss = Date2.find(:all, :conditions => "ID > ''"+ @date1 +"'' and ID <''"+ @date2+"''") and it works.. thanks, Vaibhavi -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
> I used @date2ss = Date2.find(:all, :conditions => "ID > ''"+ @date1 +"'' > and ID <''"+ @date2+"''") and it works.. > thanks, > Vaibhavi > --You can also use Model.find(:all, :conditions => {:date => date1..date2}) Andrew Timberlake http://ramblingsonrails.com http://www.linkedin.com/in/andrewtimberlake "I have never let my schooling interfere with my education" - Mark Twain --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Andrew Timberlake wrote:>> I used @date2ss = Date2.find(:all, :conditions => "ID > ''"+ @date1 +"'' >> and ID <''"+ @date2+"''") and it works.. >> thanks, >> Vaibhavi >> -- > > You can also use > Model.find(:all, :conditions => {:date => date1..date2}) > > > Andrew Timberlake > http://ramblingsonrails.com > http://www.linkedin.com/in/andrewtimberlake > > "I have never let my schooling interfere with my education" - Mark TwainThanks, -- 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?hl=en -~----------~----~----~----~------~----~------~--~---