I've been struggling with an issue all day and can't figure it out. How do you compare two datetime variables in ruby/rails?

Controller

```
@events = Event.where('date > ? AND date < ?', params[:timeMin], params[:timeMax])

```

view: index.html.erb

```
<%= form_tag events_path, :method => :get do %>
  <p>
    <%= text_field_tag :search, params[:search] %>
    <%= datetime_select :timeMin, params[:timeMin] %>
    <%= datetime_select :timeMax, params[:timeMax] %>
    <%= submit_tag "Search Near", :name => nil %>
  </p>
<% end %>

```

The Event model has an attribute 'date' which is a datetime object. I've tried converting the params[:timeMin] to a string, but them it makes it very difficult to compare times.

The overarching goal is to search for events that are happening between two times.

thanks

error - happens after search

```
SQLite3::SQLException: near ",": syntax error: SELECT "events".* FROM "events"  WHERE (date > '---
- (1i)
- ''2014''
','---
- (2i)
- ''1''
','---
- (3i)
- ''8''
','---
- (4i)
- ''14''
','---
- (5i)
- ''36''
' AND date < '---
- (1i)
- ''2014''
','---
- (2i)
- ''1''
','---
- (3i)
- ''13''
','---
- (4i)
- ''14''
','---
- (5i)
- ''36''
') ORDER BY events.created_at DESC

```