title: Export-CSV applies wrong formatting to DateTime columns of an SQL DataTable
body: <p>I am running the Powershell code included below to export the results of a simple SQL select query into a csv file. If I run the same query from SQL studio, I get a datetime like this:</p>
  
  <blockquote>
    <p>2014-08-06 15:05:49.663</p>
  </blockquote>
  
  <p>After I run it through Export-CSV and open the resultant csv file:</p>
  
  <blockquote>
    <p>8/6/2014 3:05:49 PM</p>
  </blockquote>
  
  <p>Any ideas how I can fix this in my script?</p>
  
  <p>Code:</p>
  
  <pre><code>$ConnectionString = "Server={0};Database={1};User ID={2};Password={3};Trusted_Connection=False;Connect Timeout={4}" -f $ServerInstance,$Database,$Username,$Password,$ConnectionTimeout 
  $conn=new-object System.Data.SqlClient.SQLConnection
  $conn.ConnectionString=$ConnectionString
  $conn.Open()
  $cmd=new-object system.Data.SqlClient.SqlCommand($Query,$conn)
  $cmd.CommandTimeout=$QueryTimeout
  $ds=New-Object system.Data.DataSet
  $da=New-Object system.Data.SqlClient.SqlDataAdapter($cmd)
  [void]$da.fill($ds)
  $ds.Tables[0] | export-csv -Delimiter '|' -Path 'c:\test.txt' -NoTypeInformation 
  </code></pre>