I am using excel uploading operation having date data. When I upload excel with date 17-Oct-2012 and I am getting 41199.
Asked
Active
Viewed 517 times
1
-
can you please post your code whatever you have tried? – Sandip - Frontend Developer Aug 17 '16 at 06:27
-
3There may be lots of threads available in SO regarding DataTime Formatting. How this one differ from them. Have you tried anything? – sujith karivelil Aug 17 '16 at 06:27
2 Answers
1
You need to convert the date format from OLE Automation to the .net format by using DateTime.FromOADate.
double doubleValue = double.Parse(b);
DateTime convertedDate = DateTime.FromOADate(doubleValue );

Zaheer Ahmed
- 28,160
- 11
- 74
- 110

Umut Catal
- 421
- 4
- 11
1
public static DateTime FromExcelSerialDate(int serialDate){return new DateTime(1899, 12, 31).AddDays(serialDate);}
Or other ways from old issues;
How do I convert an Excel serial date number to a .NET DateTime?