scope :reports_for, lambda { |start_date, end_date|
where("time between ? and ?", start_date, end_date)
}
Problem is the sql looks like this:
SELECT "reports".* FROM "reports" WHERE ("reports".unit_id = 1113) AND
(time between '2011-10-05 00:00:00.000000' and '2011-10-05
23:59:59.999999') ORDER BY time desc LIMIT 20 OFFSET 0
scope :reports_for, lambda { |start_date, end_date|
where("time between ? and ?", start_date, end_date)
}
Problem is the sql looks like this:
SELECT "reports".* FROM "reports" WHERE ("reports".unit_id = 1113) AND
(time between '2011-10-05 00:00:00.000000' and '2011-10-05
23:59:59.999999') ORDER BY time desc LIMIT 20 OFFSET 0
Have you noticed that these are 2011-10-05 and you said in the first sentence 2011-05-10.
Depending on which version of Ruby, a/b/YYYY where both a<=12 and b<=12, sometimes a is the month and sometimes b is the month.
Your first issue is parsing the date format as input from the user.