Hey all,

I have 90 records in database with this kind of format: 2011-05-10
11:23:15

So they are all 2011-05-10 but have different times.

User enters two dates, and just in case the two dates are the same, I
want to ensure I grab all records that span entire day.

So I do this:

unit.reports.reports_for(Date.parse('5/10/2011').beginning_of_day,Date.parse('5/10/2011').end_of_day)

But it returns empty result:

 => []

reports_for scope looks like this:

   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

Right now the user input looks like this:

unit.reports.reports_for('2011/10/05','2011/10/06')

But I want it to be in this format:

unit.reports.reports_for('2011/05/10','2011/06/10')

thanks for response

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to