title: Uploading data from Excel to SQL formatting date
body: <p>I am using VBA to upload data from and Excel file into SQL Server. The date column in the CSV as I get is in the &quot;mm/dd/yy format&quot;. How do I format the date to be in the SQL Server format &quot;YYYY-MM-DD hh:mm:ss:000&quot; before I pass it to the query to insert the record?</p>
  <p>I declare the variable</p>
  <pre><code>Dim InvoiceDate As Date
  </code></pre>
  <p>I get the value from the workbook</p>
  <pre><code>InvoiceDate = row.Cells(5).Value
  </code></pre>
  <p>I insert into the table</p>
  <pre><code>INSERT INTO table(InvoiceDate) VALUES (&quot; &amp; InvoiceDate &amp; &quot;)
  </code></pre>
  <p>I end up with this:</p>
  <pre><code>1900-01-01 00:00:00.000
  </code></pre>