Date from excel spreadsheet being converted to integer

Feb 3, 2011 at 7:41 PM

I have a web app that let's users import spreadsheets of information and one of the cells contains a date formatted as such: "1/31/2011" which is being converted to the integer result of 40209 instead of the date. Is there a way in which I can correct this in my reading code?

Apr 5, 2011 at 2:06 PM

Jimmy,

 

You can use the Datetime.FromOADate() method to convert it.

May 23, 2011 at 5:36 PM

I have a similar issue, but cannot know which column must be converted since the user can use anything as header and the column order may change.

The dll has this method: public DataSet AsDataSet(bool convertOADateTime)

and i'm using it as expected, but still cannot get the correct data type for date columns... I wrote to the developer, but no feedback yet.

Any suggestion?

May 25, 2011 at 3:22 PM

Check out the patches section. I posted a patch to fix this and other issues here:

http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=exceldatareader&DownloadId=231375

rudddenko posted a patch as well

http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=exceldatareader&DownloadId=231187

Dec 6, 2011 at 7:26 PM


We tried the above advice to fix the problem. We applied the patch to the original version and we generated new dll's and added to our project. But still the dates are converted as integers. Can anyone advice us on what might be wrong?

Feb 29, 2012 at 11:32 PM

How to apply the patch?

Feb 29, 2012 at 11:32 PM

How to apply the patch?

Jun 3, 2012 at 5:52 AM

I am facing the same issue with .xls files,, pls help someone and write detailed steps for fixing this issue

Jun 3, 2012 at 5:53 AM

I am facing the same issue with .xls files,, pls help someone and write detailed steps for fixing this issue

Jul 20, 2012 at 10:54 PM

Please help I'm using Silverlight Excel Reader and need patch for DateTime, kfriesen please is there patches for Silverlight version

Jan 2, 2013 at 1:02 PM

 

Hi, How to apply the patch?

http://exceldatareader.codeplex.com/workitem/8536


Thanks in advance!

Jan 2, 2013 at 1:55 PM

Please use DateTime.FromOADate function.

Like this:

string date1 = DateTime.FromOADate(Convert.ToDouble(dr.ItemArray[0]ToString())).ToString();

, Then did a Replace ("0:00:00", "") that needed that was only date1 date format dd-mm-yy.


Hope it will help, Greetings!

Developer
Jan 7, 2013 at 9:15 AM
FabricioPasten wrote:

 

Hi, How to apply the patch?

http://exceldatareader.codeplex.com/workitem/8536


Thanks in advance!

The patch has been incorporated into the latest code, so getting latest code should do it.