Hi Experts, I''ve a model called Product where i''ve column called created_at, updated_at where i''ve made a query based on Oracle date format like date_of_created = ''23-SEP-07'' @product = Product.find(:all, :conditions => ["created_at=?", date_of_created]) but in view its empty. AND EXPERTS I''VE DATA WITH 24-SEP-07 FOR MORE THAN 10 RECORDS, AND I''VE MINOR DOUBT BASED ON STRUCTURE OF A TABLE I MEANT THE TYPE OF CREATED_AT COLUMN, LIKE WHEN I DO MIGRATE I MADE CREATED_AT as datetime, but oracle supports date type, is there any difference? regards, Bala --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Yes, the oracle date column doesn''t contain time. Im not to sure about this but try adding .to_time to your date_of_created @product = Product.find(:all, :conditions => ["created_at=?", date_of_created.to_time]) On 9/24/07, Bala <mbbala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Hi Experts, > > > I''ve a model called Product where i''ve column called created_at, > updated_at > > > where i''ve made a query based on Oracle date format > > like > > date_of_created = ''23-SEP-07'' > @product = Product.find(:all, :conditions => ["created_at=?", > date_of_created]) > > but in view its empty. > > AND EXPERTS I''VE DATA WITH 24-SEP-07 FOR MORE THAN 10 RECORDS, AND > I''VE MINOR DOUBT BASED ON STRUCTURE OF A TABLE I MEANT THE TYPE OF > CREATED_AT COLUMN, LIKE WHEN I DO MIGRATE I MADE CREATED_AT as > datetime, but oracle supports date type, is there any difference? > > regards, > > Bala > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks Paul, it works well. but anyway is it good solution if i use created_at type as varchar to query? or it''ll be a probs? On Sep 24, 12:48 pm, "Ivor Paul" <ivorp...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Yes, the oracle date column doesn''t contain time. Im not to sure about this > but try adding .to_time to your date_of_created > > @product = Product.find(:all, :conditions => ["created_at=?", > date_of_created.to_time]) > > On 9/24/07, Bala <mbb...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hi Experts, > > > I''ve a model called Product where i''ve column called created_at, > > updated_at > > > where i''ve made a query based on Oracle date format > > > like > > > date_of_created = ''23-SEP-07'' > > @product = Product.find(:all, :conditions => ["created_at=?", > > date_of_created]) > > > but in view its empty. > > > AND EXPERTS I''VE DATA WITH 24-SEP-07 FOR MORE THAN 10 RECORDS, AND > > I''VE MINOR DOUBT BASED ON STRUCTURE OF A TABLE I MEANT THE TYPE OF > > CREATED_AT COLUMN, LIKE WHEN I DO MIGRATE I MADE CREATED_AT as > > datetime, but oracle supports date type, is there any difference? > > > regards, > > > Bala--~--~---------~--~----~------------~-------~--~----~ 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 would definitely keep it datetime. Read up about oracle date column. There are some funnies involved. I have never used oracle so not clued up. The issue here I believe is that the created_at field is datetime which contains date elements and time elements. the "23-Sept-07'' string doesn''t compare well. When you call .to_time in converts that string into a datetime object. This can then be nicely compared with the datetime field. I would rather change the way I do the query by always passing a datetime than change the database and work with strings. regards ivor On 9/24/07, Bala <mbbala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Thanks Paul, it works well. > > but anyway is it good solution if i use created_at type as varchar to > query? > > or it''ll be a probs? > > On Sep 24, 12:48 pm, "Ivor Paul" <ivorp...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Yes, the oracle date column doesn''t contain time. Im not to sure about > this > > but try adding .to_time to your date_of_created > > > > @product = Product.find(:all, :conditions => ["created_at=?", > > date_of_created.to_time]) > > > > On 9/24/07, Bala <mbb...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > Hi Experts, > > > > > I''ve a model called Product where i''ve column called created_at, > > > updated_at > > > > > where i''ve made a query based on Oracle date format > > > > > like > > > > > date_of_created = ''23-SEP-07'' > > > @product = Product.find(:all, :conditions => ["created_at=?", > > > date_of_created]) > > > > > but in view its empty. > > > > > AND EXPERTS I''VE DATA WITH 24-SEP-07 FOR MORE THAN 10 RECORDS, AND > > > I''VE MINOR DOUBT BASED ON STRUCTURE OF A TABLE I MEANT THE TYPE OF > > > CREATED_AT COLUMN, LIKE WHEN I DO MIGRATE I MADE CREATED_AT as > > > datetime, but oracle supports date type, is there any difference? > > > > > regards, > > > > > Bala > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---