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 ...
我正在获取记录,它们的created_at日期为2009-01-23 17:10:39 -0800,因为它在数据库中存储为2009-01-24 01:10:39(UTC)。
我该怎么修复这个问题,使得结果不会返回有问题的记录?
似乎我需要将日期范围转换为UTC特定或告诉find_by_sql根据当前时区搜索,而不是将列读取为UTC...
拿主意的人有吗?
约翰