title: Export dates to Csv and tell excel the format
body: <p>My program (C# .Net 4.5) have to be able to generate some reports which can be loaded into Excel.
  I have choosen to export the reports as .csv format due to it being the most simple way to export to a format excel understands.
  And it does not requre Excel to be installed on the machine running my program. </p>
  
  <p>My problem is exporting the dates.</p>
  
  <p>My program is going to run on customer PC's which may (most likely) have different ways to show dates, which means excel expects dates in different formats. </p>
  
  <p>My current solution is to export dates as:</p>
  
  <pre><code>DateTime LogTime = DateTime.Now;
  String TimeFormat = //The format for the specific location, like: "HH:mm:ss dd/MM-yyyy"
  
  //To csv:
  // ="10:24:13 27-05-2014"
  String reportTime = "=\""+LogTime.ToString(TimeFormat)+"\"";
  </code></pre>
  
  <p>The problem with this is i create different files based on different locations. So sending a file from one location to another may result in the date being wrong. </p>
  
  <p>My question is, are there someway to tell Excel which format my date is in?
  Something like:</p>
  
  <pre><code>//To csv:
  // =DateFormatted(10:24:13 27-05-2014,HH:mm:ss dd/MM-yyyy)
  String reportTime = "=DateFormatted(" + LogTime.ToString(TimeFormat) + "," + TimeFormat + ")";
  </code></pre>
  
  <p>Then Excel know the exactly how to read the dates without I have to worry about different locations. </p>