title: Filtering by date substrings in Rails
body: <p>We have a grid control that allows a user to filter text in different fields. A number of these fields might be timestamps, like created_at and updated_at.</p>
  
  <p>Now, a user can do many different types of filters, including >, &lt;, >=, &lt;=, etc. So, a query that comes across from the control might look like:</p>
  
  <p>"created_at > 2009", or "created_at >= 2006 and created_at &lt;= 2010".</p>
  
  <p>The database doesn't recognize years as valid timestamps, nor does rails automatically convert them as such. Are there any plugins or idiomatic ways to accomplish taking a year, or better yet, portion of a timestamp, making a best guess at the meaning, and converting it into a usable database timestamp?</p>