Hi,
I want to get models whom date is within a date range. So I want to do something like
MyModel.find_all_by_field1_id_and_field2_id(value1, value2, :conditions => { :date => nb_days_ago..Date.yesterday })
The thing is, the date attribute of my model is a string (with the format "08-24-2010"), and I can't modify this. So to compare it to my range of dates, I tried this:
MyModel.find_all_by_field1_id_and_field2_id(value1, value2, :conditions => { Date.strptime(:date, "%m-%d-%Y") => nb_days_ago..Date.yesterday })
But I get an error that basically says that strptime can't process the :date symbol. I think my solution is not good.
How can I compare my string to my range of dates ?
Thanks