title: Mysql error getting the previous dated record
body: <p>First a select a row from 'table' </p>
  
  <pre><code>$query_set1 = "SELECT * FROM table WHERE ordinal = 5555 ";
  $set1 = mysql_query($query_set1, $table));
  $row_set1 = mysql_fetch_assoc($set1);
  </code></pre>
  
  <p>Then I want to select the previous dated record</p>
  
  <pre><code>$query = sprintf("SELECT * FROM table WHERE date = (SELECT MAX(date) FROM table WHERE date &lt; %s) ", $row_set1['date']);
  </code></pre>
  
  <p>I get this error</p>
  
  <blockquote>
    <p>You have an error in your SQL syntax; check the manual that
    corresponds to your MySQL server version for the right syntax to use
    near '08:43:30)' at line 1</p>
  </blockquote>
  
  <p>And this is the interpreted $query</p>
  
  <pre><code>SELECT * FROM table WHERE date = (SELECT MAX(date) FROM table WHERE date &lt; 2014-08-07 08:43:30)
  </code></pre>