title: Convert time-formatted column in excel to C# DateTime
body: <p>I am currently using the Excel C# libraries (Microsoft.Office.Interop.Excel) to read an excel spreadsheet into my C# application. </p>
  
  <p>I initially tried to read all the cells as their raw data, but found that Date-formatted cells were giving me a 5-digit integer, and time-formatted cells were returning a decimal. So I then found out that you can use a date-conversion method built into Excel's C# library, like so:</p>
  
  <pre><code>DateTime excelDate = (DateTime)ExcelCalcValue.ExcelDateToDateTime(workbook, Double.Parse(cell.Value.ToString()));
  output = excelDate.ToString("yyyy-MM-dd HH:mm");
  </code></pre>
  
  <p>Through debugging my application with various test sheets, I have been able to record the various format strings that cells return when they are formatted in different ways. These are below:</p>
  
  <pre><code>(WorksheetCell.CellFormat.FormatString)
  
  Times
  
  [$-F400]h:mm:ss\\ AM/PM
  hh:mm:ss;@
  h:mm:ss;@
  [$-409]hh:mm:ss\\ AM/PM;@
  [$-409]h:mm:ss\\ AM/PM;@
  
  Dates
  
  m/d/yy
  [$-F800]dddd\\,\\ mmmm\\ dd\\,\\ yyyy
  dd/mm/yyyy;@
  dd/mm/yy;@
  d/m/yy;@
  d\\.m\\.yy;@
  yyyy\\-mm\\-dd;@
  [$-809]dd\\ mmmm\\ yyyy;@
  [$-809]d\\ mmmm\\ yyyy;@
  </code></pre>
  
  <p>Using these, I can now reliably determine the formatting style of a cell in excel. Using the earlier code, I can detect a date-formatted cell and return the proper data in DateTime format. However, I cannot see an equivalent function for converting time-formatted cells.</p>
  
  <p>I get a result of <code>0.58368055555555554</code> when I read a cell time-formatted as <code>[$-F400]h:mm:ss\\ AM/PM</code>. I have absolutely no idea how to convert this into a <code>DateTime</code>, or indeed what this float represents.</p>
  
  <p>Can anyone suggest a method of converting time-formatted excel cells (which are stored as a strange float) into the correct <code>DateTime</code> variable?</p>