title: get the nearest date mysql
body: <p>I have the following dates in my table. How do I find a closest date from either today (if today's date is there) or if today's date is not there then the nearest past date?</p>
  
  <pre><code>2012-10-01          aa123
  2012-10-02          aa43
  2012-10-03          aa478
  2012-10-04          aa40    
  2012-10-05          aa54
  2012-10-06          de34
  2012-10-07          a5434
  2012-10-08          r4t
  2012-10-09          x34
  2012-10-10          q23
  2012-10-11          b53
  </code></pre>
  
  <p>So if today is <code>'2012-10-07'</code> is then the record will be <code>a5434</code>. But if <code>2012-10-07</code> is missing then the record will be <code>de34</code> which belongs to <code>2012-10-06</code> since that would be the closest past day from today.</p>
  
  <p>I am not sure where to start on this one, so I haven't tried anything yet. Need a sql solution to this.</p>