title: Ordering by date in mySQL not working with a simple query?
body: <p>I'm trying to order a list of MySQL results by date, putting on top the more recent ones.</p>
  
  <p>This is my query (I've added the formatted date field in order to easily see if the order shown is correct):</p>
  
  <pre><code>  SELECT DISTINCT contenidoID, titulo, fecha, 
    DATE_FORMAT(FROM_UNIXTIME(fecha), '%d-%m-%Y') AS date
    FROM contenidos
    WHERE publicado = 1
    ORDER BY fecha DESC
  </code></pre>
  
  <p>The <strong>fecha</strong> field is a <strong>string</strong> field.</p>
  
  <h2>The expected result is:</h2>
  
  <pre><code>2886 | pagina estática                                      | 1525662000 | 06-05-2018
  1012 | Plan aprender conectados                             | 1525274828 | 02-05-2018
  1011 | En el día del trabajador, una historia               | 1525191654 | 01-05-2018
   485 | Sobre la Corte Suprema de Justicia                   | 1524932656 | 28-04-2018
   484 | Empresa de electrodomésticos responde                | 1524925652 | 28-04-2018 
   483 | La obra social debe cubrir los gastos de escolaridad | 1524658737
  </code></pre>
  
  <h2>The result that I get is:</h2>
  
  <pre><code>1419 | Obligaciones de los Propietarios                     |  982428253 | 17-02-2001
  1092 | Modificaciones al Código Contravencional             |  965444400 | 04-08-2000
  2222 | Ley de Expropiaciones de la CABA                     |  962060969 | 26-06-2000
  2886 | pagina estática                                      | 1525662000 | 06-05-2018
  1012 | Plan aprender conectados                             | 1525274828 | 02-05-2018
  1011 | En el día del trabajador, una historia               | 1525191654 | 01-05-2018
   485 | Sobre la Corte Suprema de Justicia                   | 1524932656 | 28-04-2018
   484 | Empresa de electrodomésticos responde                | 1524925652 | 28-04-2018
   483 | La obra social debe cubrir los gastos de escolaridad | 1524658737
  </code></pre>
  
  <p><strong>Why are those old results appearing at the top of the list?!</strong></p>
  
  <p><strong>IS THIS A DUPLICATED POST?</strong> I've been reading quite a few date issues with mysql responses here before I've posted this message, but in all cases I've found that the query was somehow more complex and the answer didn't apply to this, or there was some PHP code involved. I'll be more than happy to close this in case there's out there an actual answer for this and someone can point that out to me. Thanks!</p>