php date string sql server 2008 insert
<p>Trying to insert date as a string from array to SQL Server 2008 and getting this error </p>

<blockquote>
  <p>Array ( [0] => Array ( [0] => 22007 [SQLSTATE] => 22007 [1] => 241 [code] => 241 [2] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Conversion failed when converting date and/or time from character string. [message] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Conversion failed when converting date and/or time from character string. ) ) </p>
</blockquote>

<p>The insert array is like this </p>

<pre><code>$data = array(
    'date' =&gt; '2012-10-12',
    'time' =&gt; '10:37:10'
);
</code></pre>

<p>date field datatype date
time field datatype time(7)</p>

<pre><code>$sql = "INSERT INTO test (p_date, p_time) VALUES (?, ?)";

$stmt = sqlsrv_prepare($conn, $sql, array(&amp;$data['date'], &amp;$data['time']));

if( sqlsrv_execute($stmt) === false) 
{
    die( print_r( sqlsrv_errors(), true));
}
</code></pre>
