title: Rails :order by date in Postgres returning incorrect order
body: <p>I have a model called <code>Story</code> that I'm trying to order by the <code>created_at</code> date. Since I've hosted my app on Heroku, which uses Postgresql, I have the following in my controller:</p>
  
  <pre><code>@stories = Story.find( :all, :order =&gt; "DATE(created_at) DESC" , :limit =&gt; 11)
  </code></pre>
  
  <p>I would expect this to give the first 11 of my stories, ordered by the creation date, with the newest story first.</p>
  
  <p>Unfortunately, this doesn't work. Most of the stories return ordered correctly, but the first two are flipped. That is, the latest story appears second in the list.</p>
  
  <p>Why would this be? I have a sneaky suspicion that my results aren't ordered at all or are being ordered on the wrong column (maybe id?) and that until now it just happened to be ordered like I expected when displayed on my index page. How can I get it to order as I expect it to?</p>
  
  <p>In case anyone cares, the index view is simply displaying the stories, in order. That is (HAML):</p>
  
  <pre><code>- @stories.each do |story|
    = render :partial =&gt; "event", :locals =&gt; { :event =&gt; story }
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>I am suspicious that the <code>created_at</code> is a datetime column and the <code>DATE(...)</code> function disregards the time portion. So it returns the elements created on the same date in a random order. Since the first two stories were created on the same day, but several hours apart, which would explain why they seem to be 'reversed'. If this is the case, what would be the correct syntax to order by both date and time?</p>