Hi all, i have User model with bdate: string Try :> User.find(2).bdate > => Wed, 09 May 1945 > User.find(2).bdate.to_s > => "1945-05-09"But if i run:> User.where(bdate: "1945-05-09") > => []Why??? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/2989915a-d24e-491f-87e2-efb061910ff2%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
On 19 November 2013 14:07, rusik <rusik3-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi all, i have User model with bdate: string > Try : >> >> User.find(2).bdate >> => Wed, 09 May 1945 >> User.find(2).bdate.to_s >> => "1945-05-09"Are you sure bdate is of type string in the database? If so then why does it appear to interpret it as a date in your first example? Colin> > But if i run: >> >> User.where(bdate: "1945-05-09") >> => [] > > Why??? > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msgid/rubyonrails-talk/2989915a-d24e-491f-87e2-efb061910ff2%40googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLsdYdGT4Q5mumHSa1WQxJK3bkLveQgY8DXLhu%2BhqOTSRQ%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
yes, it is string. I find decision , i am using date without zero''s like this: User.where(bdate: "1945-5-9") вторник, 19 ноября 2013 г., 19:09:01 UTC+4 пользователь Colin Law написал:> > On 19 November 2013 14:07, rusik <rus...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:>> wrote: > > Hi all, i have User model with bdate: string > > Try : > >> > >> User.find(2).bdate > >> => Wed, 09 May 1945 > >> User.find(2).bdate.to_s > >> => "1945-05-09" > > Are you sure bdate is of type string in the database? If so then why > does it appear to interpret it as a date in your first example? > > Colin > > > > > But if i run: > >> > >> User.where(bdate: "1945-05-09") > >> => [] > > > > Why??? > > > > -- > > You received this message because you are subscribed to the Google > Groups > > "Ruby on Rails: Talk" group. > > To unsubscribe from this group and stop receiving emails from it, send > an > > email to rubyonrails-ta...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>. > > To post to this group, send email to rubyonra...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<javascript:>. > > > To view this discussion on the web visit > > > https://groups.google.com/d/msgid/rubyonrails-talk/2989915a-d24e-491f-87e2-efb061910ff2%40googlegroups.com. > > > For more options, visit https://groups.google.com/groups/opt_out. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/f17e6c63-7c0c-41a5-91dd-26baa41cde96%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
On Tue, Nov 19, 2013 at 10:36 AM, rusik <rusik3-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> yes, it is string.Uh, well. If the datatype of that column were String, would you think you''d be likely to get different results from bdate and bdate.to_s?>> >> User.find(2).bdate >> >> => Wed, 09 May 1945 >> >> User.find(2).bdate.to_s >> >> => "1945-05-09"-- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org http://about.me/hassanschroeder twitter: @hassan -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yBrz8Z1c7XdHDyGO6ozgWPvCUKyTWN3-uSX0_O4DaJMDQ%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
On 19 November 2013 18:36, rusik <rusik3-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> yes, it is string. I find decision , i am using date without zero''s like > this:Just to convince us show us the users table entry from db/schema.rb. Colin> User.where(bdate: "1945-5-9") > вторник, 19 ноября 2013 г., 19:09:01 UTC+4 пользователь Colin Law написал: >> >> On 19 November 2013 14:07, rusik <rus...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> > Hi all, i have User model with bdate: string >> > Try : >> >> >> >> User.find(2).bdate >> >> => Wed, 09 May 1945 >> >> User.find(2).bdate.to_s >> >> => "1945-05-09" >> >> Are you sure bdate is of type string in the database? If so then why >> does it appear to interpret it as a date in your first example? >> >> Colin >> >> > >> > But if i run: >> >> >> >> User.where(bdate: "1945-05-09") >> >> => [] >> > >> > Why??? >> > >> > -- >> > You received this message because you are subscribed to the Google >> > Groups >> > "Ruby on Rails: Talk" group. >> > To unsubscribe from this group and stop receiving emails from it, send >> > an >> > email to rubyonrails-ta...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> > To post to this group, send email to rubyonra...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> > To view this discussion on the web visit >> > >> > https://groups.google.com/d/msgid/rubyonrails-talk/2989915a-d24e-491f-87e2-efb061910ff2%40googlegroups.com. >> > For more options, visit https://groups.google.com/groups/opt_out.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLv0HsuPaOkEwyGAELtnw8y4yYbAmTFfhoRvLOKVGaAP7A%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
Colin Law wrote in post #1127964:> On 19 November 2013 18:36, rusik <rusik3-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> yes, it is string. I find decision , i am using date without zero''s like >> this: > > Just to convince us show us the users table entry from db/schema.rb.Just a thought, but if the birthday is truly being stored in a string (varchar) field, doesn''t that make localizing your application somewhat more difficult? 05/09/1945 - U.S.A 09.05.1945 - Europe 1945年5月9日 - Japan Wednesday, May 9, 1945 - U.S.A Long Format -- 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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/54c45be19d24af9049f0baa7f39e7d53%40ruby-forum.com. For more options, visit https://groups.google.com/groups/opt_out.