-1

I read an excel (xslx) file with this library: http://www.codeproject.com/Tips/801032/Csharp-How-To-Read-xlsx-Excel-File-With-Lines-of

The excel sheets contain some time values. It seems that excel converts this values to Time strings.

If i take a look into the source files of the sheets in the excel zip the time values are numbers that looks like this:

40056.583055555559

Does someone know which format this is and how i can convert it into a time string or time ticks?

xlw12
  • 761
  • 1
  • 7
  • 16

1 Answers1

1

Excel stores date/time values in a double (floating point) value, where the whole portion (the part to the left of the decimal point) is the number of days since midnight 12/30/1899, and the time is encoded in the fractional portion (the part to the right of the decimal). The time is expressed as the fractional part of a day; for instance, 6:00 AM is 0.25, 12:00 noon is 0.5, 6:00 PM is 0.75.

Excel doesn't "convert" the values to Time strings. It simply displays it as a time string; the actual value is the floating point number.

The value you posted represents August 31, 2009 at 13:59:36 (1:59:36 PM).

You can convert it to a .NET compatible DateTime value with DateTime.FromOADate.

Ken White
  • 123,280
  • 14
  • 225
  • 444