title: Export Datetime Format into Excel from Microsoft SQL Server
body: <p>Exporting data from SQL Server to Excel seems like a reasonably simple request.  I just need to write out a few reports for users on a regular basis, nothing too fancy, the same basic report with a few different parameters.
  I am doing this by OPENROWSET:</p>
  
  <pre><code>INSERT INTO OPENROWSET(
              'MICROSOFT.ACE.OLEDB.12.0'
              ,'Excel 12.0;Database=C:\test1.xlsx;'
              ,'SELECT * FROM [BCT$]'
              ) 
  </code></pre>
  
  <hr>
  
  <p>I am successful to export all data into excel file from stored procedure of sql server. but problem is format of data like,
  DateTime &amp; Number format.</p>
  
  <p>When I export database datetime value into excel than it stored in <strong>Mar 18 2014  6:29PM</strong> this format but actually it was in database like, <strong>2014-03-18 18:29:00</strong>. </p>
  
  <p>I require this format of datetime  <strong>2014-03-18 18:29:00</strong> into Excel. </p>
  
  <p>I have tried different option like :</p>
  
  <ul>
  <li>Cast require column into datetime , during preparation of last select list.</li>
  <li>I have set one blank excel file in which I have set datetime format on require column. </li>
  <li>I have also check my default windows regions and time zone which is also correct. </li>
  </ul>
  
  <p>When I export datetime value into excel then it by default convert into text so I can't perform any further operation like ordering into this column. </p>
  
  <p>Please help me in this. </p>
  
  <p>Thanks in Advance !.</p>