I have a model called Result. I need to create a variable that returns all results between a specific date range. The result model has a field called a date, and in the form I take the start and end date as parameters and pass them back to the controller.
therefore, if the user enters '01 / 01/2014 'in the startdate parameter and '01 / 01/2015 in the parameters, I need to return all the results where the date is between this range.
When the user clicks the filter button, the parameters are eventually captured as startdate and enddate variables
I tried this but it does not work
@results = Result.where("date >= ? and date <= ?", startdate, enddate")
Then I looked at the resulting SQL and thought it should be
@results = Result.where("date >= ? and date <= ?", '#{startdate)', '#{enddate}')
Any ideas?
thank