Does anyone know what this means. Getting this in C# winforms applications:
Not a legal OleAut date
What I found was that a column with a large row_id '257381195' was attempting to be read by Excel as a Date. What I ended up doing was altering that column's data to a string by preceding the row_id with a single quote. This resolved my issue. Hope this helps.
I've used:
try
{
if (folderItem.ModifyDate.Year != 1899)
{
this.FileModifiedDate = folderItem.ModifyDate.ToShortDateString() +
" " +
folderItem.ModifyDate.ToLongTimeString();
}
}
//we need this because it throws an exception if it's an invalid date...
catch (ArgumentException) { }
to deal with the same problem I'm having. It throws the exception when we check the year in my case. Doing nothing on an invalid date is exactly the behavior I want, so this hack works.
It means you provided an invalid date somewhere, attempting to convert to or from an OLE Automation date outside the valid range 1-January-4713 BC to 31-December-9999 AD. A possible cause is that it might have slipped through because OLE Automation Dates are represented as a double.
It means that somewhere in the program is attempting to convert to or from an OLE Automation Date outside the valid range 1-January-4713 BC to 31-December-9999 AD. It might have slipped through because OLE Automation Dates are represented as a double.
Start by looking for any uses of the methods:
DateTime.FromOADate
DateTime.ToOADate
An OADate is represented as a double value whose value is the number of days from midnight on 30 december 1899 (negative values representing earlier dates).
This exception is thrown when trying to convert a value that is outside the valid range of Ole Automation dates to/from a .NET DateTime value (methods DateTime.FromOADate and DateTime.ToOADate - which are also used implicitly for COM Interop).
I believe to be valid for conversion to an OADate the .NET DateTime value needs to be strictly greater than 01/01/0100.
To convert from OADate to a .NET DateTime value, the double value needs to be strictly greater than -657435 (= 01/01/0100) and strictly less than 2958466.0 (01/01/10000).
Others have struggled with this. I suggest looking at these threads on DotNetNuke and DevShed.