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???
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???
On 19 November 2013 14:07, rusik [email protected] 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
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 L. :
On 19 November 2013 18:36, rusik [email protected] 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
Colin L. wrote in post #1127964:
On 19 November 2013 18:36, rusik [email protected] 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
On Tue, Nov 19, 2013 at 10:36 AM, rusik [email protected] 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 S. ------------------------ [email protected]
twitter: @hassan
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs