title: Converting from SQL Date to DateTime in Delphi XE
body: <p>I've searched google and SO with no usable fixes for this. I am retrieving a <code>date</code> from a table in SQL Server. I need to convert this to a <code>DateTime</code> object in Delphi. The problem seems to lie in the value coming in from SQL. The version of SQL Server on which I am testing this is SQL Server 2012 (not R2).</p>
  
  <p>If I display the value retrieved from a query as a string I get:</p>
  
  <pre><code>myQuery.FieldByName('ActiveDate').AsString;
  </code></pre>
  
  <p>I get the value</p>
  
  <pre><code>2014-06-15
  </code></pre>
  
  <p><code>myQuery</code> is a TADOQuery type.</p>
  
  <p>DateTime doesn't seem to like this format since all of these fail:</p>
  
  <pre><code>myQuery.FieldByName('ActiveDate').AsDateTime;
  StrToDateTime(myQuery.FieldByName('ActiveDate').AsString);
  StrToDate(myQuery.FieldByName('ActiveDate').AsString);
  </code></pre>
  
  <p>The failure message from the caught exception that gets logged is:</p>
  
  <pre><code>''2014-06-15'' is not a valid date and time
  </code></pre>
  
  <p>Is there a solution to this that doesn't involve a complicated string manipulation and that would not be affected by the locale of the server?</p>