title: Rails 3 DateTime and Time beginning_of_day end_of_day format incorrect
body: <p>I am trying to find events on certain days with this code:</p>
  
  <pre><code>Event.where('starttime BETWEEN ? AND ?', DateTime.now.beginning_of_day, DateTime.now.end_of_day)
  </code></pre>
  
  <p>In rails console if I run <code>DateTime.now.beginning_of_day</code> I get exactly what I expect:</p>
  
  <p>Mon, 09 Apr 2012 00:00:00 -0700</p>
  
  <p>I can see where the problem is occurring but looking at the SQL in rails console. Somehow when the date makes it into the SQL query it gets automatically formatted to the wrong date and time.</p>
  
  <pre><code>SELECT "events".* FROM "events" WHERE (starttime BETWEEN '2012-04-09 07:00:00' AND '2012-04-10 06:59:59')
  </code></pre>
  
  <p>This is giving me results that vary from today until tomorrow, as the sql above says. I can see that when the DateTime.now.beginning_of_day also DateTime.now.end_of_day are being formatted incorrectly once they make it into the sql query. Do I need to be formatting this in a certain way? Any idea why it would go to 7:00 of today and 7:00 of tomorrow?</p>
  
  <p>I don't know if it makes a difference but I'm using PostgreSQL.</p>
  
  <p>Thanks!</p>