title: Compare two dates in MySQL
body: <p>I have records in mysql database and every record has expired date 
  so I want to select expired records from my database 
  this is the contents of my table:</p>
  
  <pre class="lang-none prettyprint-override"><code>+-------------+-------------+----------------------+
  | username    | attribute   | value                |
  +-------------+-------------+----------------------+
  | ali         | Expiration  | 22 Jan 2018 01:01:30 |
  | jon         | Expiration  | 10 Jan 2018 02:02:55 |
  | goerge      | Expiration  | 22 Feb 2018 12:03    |    
  +-------------+-------------+----------------------+
  </code></pre>
  
  <p>As you can see I have 2 Expired Accounts 
  and when I trying to select these expired Records I have <code>NULL</code> results.</p>
  
  <p>This is my Query:</p>
  
  <pre class="lang-sql prettyprint-override"><code>SELECT *
  FROM radcheck
  WHERE DATE_FORMAT(STR_TO_DATE(e.value, '%d %M %y'), '%d %M %y')
    &lt;= DATE_FORMAT(NOW(), '%d %M %y');
  </code></pre>
  
  <p>but the query result show this records </p>
  
  <pre class="lang-none prettyprint-override"><code>+-------------+-------------+----------------------+
  | username    | attribute   | value                |
  +-------------+-------------+----------------------+
  | ali         | Expiration  | 22 Jan 2018 01:01:30 |
  | jon         | Expiration  | 10 Jan 2018 02:02:55 |
  | goerge      | Expiration  | 22 Feb 2018 12:03    |
  +-------------+-------------+----------------------+
  </code></pre>
  
  <p>Even if the second record (jon) is not expired yet.
  Where is the mistake? </p>