Quantcast
Channel: Excel Data Reader - Read Excel files in .NET
Viewing all articles
Browse latest Browse all 448

Created Unassigned: DateTime parsing error - the OADate is wrong [12456]

$
0
0
The date that is parsed by excel data reader is a few years off.

When parsing '9/8/2013' exceldatareader is giving me 40056
When it should actually be 41525


Using the attached xls file, dates are converted wrongly.

void Main()
{
var dt = DateTime.Parse("9/8/2013");
Double d = dt.ToOADate();
Console.WriteLine(d);
Console.WriteLine(DateTime.FromOADate(d));

// output from exceldata reader
Console.WriteLine(DateTime.FromOADate(40056));
}


Output

41525
9/8/2013 12:00:00 AM
8/31/2009 12:00:00 AM

Viewing all articles
Browse latest Browse all 448

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>