title: MySQL to SQL Server: The conversion of a nvarchar data type to a datetime
body: <p>I get this error message:</p>
  
  <blockquote>
    <p>The conversion of a nvarchar data type to a datetime</p>
  </blockquote>
  
  <p>when I try to bind a MySQL <code>datetime</code> variable to a <code>smalldatetime</code> variable in SQL Server statement. The code looks like:</p>
  
  <pre><code>$s = $dbcnx-&gt;prepare("SELECT MAX(attr_81577_) AS max_date FROM object_70969_");
  $s-&gt;execute();
  $r = $s-&gt;fetch(PDO::FETCH_ASSOC);
  $max_date = $r[max_date]; // we got the maximum date from MySQL table
  
  $s = $dbms-&gt;prepare("SELECT * FROM orgs WHERE update_date &gt;= :max_date"); // Now we want to filter SQL Server table based on $max_date value
  $s-&gt;bindParam(':max_date', $max_date);
  $s-&gt;execute();
  </code></pre>
  
  <p>What is wrong with that and what can I do?</p>