title: How to Properly Convert or Query Date Range for Rails / MySQL DateTime Column
body: <p>I have a rails application where I store created_at as datetime (standard).
  I am building a form for searching and I find I have to use find_by_sql to do some complex subqueries. The form has a date range (no time) to search on for items created_at field.</p>
  
  <p>The problem I find is that if I pass in just the date string for range to query... </p>
  
  <pre><code>... status_changes.created_at between '2009-01-24' and '2009-03-12' ...
  </code></pre>
  
  <p>I am getting back records that have a created_at date of 2009-01-23 17:10:39 -0800 because this is stored in the db as 2009-01-24 01:10:39 (UTC) </p>
  
  <p>How can I fix this so that the result is not returning the record in question?</p>
  
  <p>It seems I either need to convert the date range to be UTC specific or tell the find_by_sql to search based on current time zone instead of reading the column as utc... </p>
  
  <p>Any takers?</p>
  
  <p>John</p>