我正在使用between子句执行rails_admin gem的默认搜索。它正在进行以下查询。
SELECT `booking_reports`.* FROM `booking_reports` WHERE ((booking_reports.booking_date BETWEEN '2014-04-30 22:00:00.000000' AND '2015-05-02 21:59:59.999999')) ORDER BY booking_reports.id asc LIMIT 20 OFFSET 0
但查询应该是
SELECT `booking_reports`.* FROM `booking_reports` WHERE ((booking_reports.booking_date BETWEEN '2014-04-30 23:59:59.000000' AND '2015-05-02 23:59:59.999999')) ORDER BY booking_reports.id asc LIMIT 20 OFFSET 0
或
SELECT `booking_reports`.* FROM `booking_reports` WHERE ((booking_reports.booking_date BETWEEN '2014-04-30 23:59:59.000000' AND '2015-05-01 23:59:59.999999')) ORDER BY booking_reports.id asc LIMIT 20 OFFSET 0
请参阅以下图片和查询提供的记录
日期的默认格式为IST (Thu, 01 May 2014 23:08:05 IST +05:30)
。 IST格式存储在数据库中。
答案 0 :(得分:0)
我将此添加到config / application.rb
中config.time_zone = 'New Delhi'
config.active_record.default_timezone = 'New Delhi'
现在日期的格式符合我的时区,现在查询也很准确。