I have a rails application where I store created_at as datetime (standard). I am building a form for searching and I find I have to use find_by_sql to do some complex subqueries. The form has a date range (no time) to search on for items created_at field.
The problem I find is that if I pass in just the date string for range to query...
... status_changes.created_at between '2009-01-24' and '2009-03-12' ...
I am getting back records that have a created_at date of 2009-01-23 17:10:39 -0800 because this is stored in the db as 2009-01-24 01:10:39 (UTC)
How can I fix this so that the result is not returning the record in question?
It seems I either need to convert the date range to be UTC specific or tell the find_by_sql to search based on current time zone instead of reading the column as utc...
Any takers?
John