Hi All,
I have a quick question related to activerecord exist. Can we do a activerecord object exist method with a date field. Like
Weather.exists?(:weather_date => 22/09/11 )
Can we do like above. Please clarify me.
Hi All,
I have a quick question related to activerecord exist. Can we do a activerecord object exist method with a date field. Like
Weather.exists?(:weather_date => 22/09/11 )
Can we do like above. Please clarify me.
Yes (you should use a date object or a string containing a date in a format the database will understand) The only caveat is that if the column is actually a datetime column then you need to check for the range of datetimes that make up that particular day)
Fred
Weather.exists?(:weather_date => 22/09/11 )
if data is a string containing '22/09/11'
Check whether it works..
Weather.exists?(:weather_date => data.to_date )
or check
date rdoc clearly for correct format