I have a rails application where I store created_at as datetime (standard). I am creating a search form and I believe that I need to use find_by_sql to execute complex subqueries. The form has a date range (no time) for searching the created_at fields.
The problem I find is that if I only pass a date string for a range request ...
... status_changes.created_at between '2009-01-24' and '2009-03-12' ...
I am returning records that have the created_at date 2009-01-23 17:10:39 -0800, because it is stored in db as 2009-01-24 01:10:39 (UTC)
How can I fix this so that the result does not return this record?
It seems I need to either convert the date range to UTC, or tell find_by_sql to search based on the current time zone instead of reading the column as utc ...
Any members?
John
ruby sql mysql datetime ruby-on-rails
Streamline
source share