title: MS SQL Server Dates Excel
body: <p>I have data this is linked from SQL Server into an excel document. The column format on the SQL Server is <code>datetime2</code>. </p>
  
  <p>When I get the data via an ODBC connection it comes across as a string?</p>
  
  <p>I tried using </p>
  
  <pre><code>CAST(column AS DATE ) 
  </code></pre>
  
  <p>but that didn't work.</p>
  
  <p>I tried reformatting via </p>
  
  <pre><code>CONVERT(VARCHAR(10), column, 103) 
  </code></pre>
  
  <p>as well but that didn't work.</p>
  
  <p>I tried retrieving the data via Microsoft query as well but that didn't work.</p>
  
  <p>At the moment I am using VBA code like:</p>
  
  <pre><code>While (ActiveCell.Value &lt;&gt; "")
    ActiveCell.Value = DATEVALUE(ActiveCell.Value)
    ActiveCell.Offset(1,0).Activate
  Wend
  </code></pre>
  
  <p>and looping through each column that needs this treatment but 100000 rows in multiple columns takes forever to loop through. Are there any alternatives?</p>