title: SQL - ORDER BY 'datetime' DESC
body: <p>I have several values stored in my database as the <code>DATETIME</code> datatype (<strong>YYYY-MM-DD HH:MM:SS</strong>), and I've been trying to get them in a descending order - Greatest to least (In the case of dates - Newest to oldest), though, oddly enough, it seems to ignore the existence of the <strong>DESC</strong> operator entirely.</p>
  
  <p>The SQL query (Abbreviated):</p>
  
  <pre><code>SELECT post_datetime FROM post WHERE type=`published` ORDER BY post_datetime DESC LIMIT 3
  </code></pre>
  
  <p>And from that, they print in this order:</p>
  
  <pre><code>2014-04-30 11:55:11
  2014-07-01 12:25:40
  2014-07-02 12:28:03
  </code></pre>
  
  <p>(Those happen to be the "oldest" date entries in the database too)</p>
  
  <p>Solution? I'll note that using DESC on other things (Such as normal numbers) doesn't work either. I've checked my syntax, tried quotes, no quotes, double quotes &amp; such.</p>
  
  <p>(<em>Note</em> - I won't be able to answer any further questions for several hours, though I'll do my best to respond once I return)</p>
  
  <hr>
  
  <p><strong><em>(6/11/17)</em></strong></p>
  
  <p><strong>Edit</strong>: To clarify, for future readers, the syntax typo was not related to the issue and was an error on my part when typing an example. I had been using a homemade query builder for so long that I had forgotten the proper syntax at the time. The issue lied within my program's logic—not the query. The above example has been edited and <em>is</em> correct solution for anyone looking to perform the mentioned task. I'm sorry this has been viewed over 50k times... but now you know.</p>