title: PDO wrong date binding
body: <p>I'm querying a mssql 2008 database via odbc and stubled upon a strange behaviour.</p>
  
  <p>The following code is used...</p>
  
  <pre><code>$datefrom = "2009-06-01";
  $dateto = "2009-07-01";
  $clientno = "01";
  $sth = $db-&gt;prepare("select count(*) from tbl WHERE v_valid_from &lt;= ? and valid_from &lt;= ? and (v_invalid_from &gt;= ?) and (valid_to &gt;= ? or valid_to is null) and clientno = ?");
  $sth-&gt;execute(array($datefrom, $datefrom, $dateto, $dateto, $clientno));
  </code></pre>
  
  <p>the query retrieves 80 rows though 1000 were expected.</p>
  
  <p>Looking in the profiler, the server executes the following statement:</p>
  
  <pre><code>select count(*) from tbl 
  WHERE v_valid_from &lt;= '20090601 00:00:00.000' and valid_from &lt;= '20090601 00:00:00.000' and 
  (v_invalid_from &gt;= '20090701 00:00:00.000') and (valid_to &gt;= '20090701 00:00:00.000' or valid_to is null) and clientno = '01'
  </code></pre>
  
  <p>when I put '-' in the dates, the query is executed properly.</p>
  
  <p>There seems to be no special binding for datetime-values so I'm wondering why this happens.</p>
  
  <p>The session settings are as following:</p>
  
  <pre><code>set quoted_identifier on
  set arithabort off
  set numeric_roundabort off
  set ansi_warnings on
  set ansi_padding on
  set ansi_nulls on
  set concat_null_yields_null on
  set cursor_close_on_commit off
  set implicit_transactions off
  set language English
  set dateformat ymd
  set datefirst 1
  set transaction isolation level read committed
  </code></pre>