How to validate dates in a corrupted database
Posted: Fri Oct 06, 2017 1:22 am
I have a .dbf file. Three of the fields are type DATE.
The file has had some corrupted values in it. As I skip through the database, sometimes the system will throw an error because one of the date fields values is somehow wrong.
The error is ADSCDX 5095 : Cannot convert to a Juliene date. It sees the date time stamp as a negative value but I can't see anything in the field.
So, here is my question. How can I test the dates in record fields to prevent the error from occurring. In other words, if the date is invalid ( or corrupted ), I want to place a default value in it's place.
The line of code failing:
AADD( aPMitems, { oPMtable:PMSCOD, dBaseD, 0, oPmtable:recno() } )
The file is oPMtable. dBaseD is simply CTOD( "01/01/80" ). The problem is not here, but when database.prg skips to the record, apparently it does not like one of the values in the date fields it sees. It fails at line 1048:
for n = 1 to Len( ::aBuffer )
::aBuffer[ n ] = ( ::cAlias )->( FieldGet( n ) )
next
SO ... Any thoughts on a strategy here to trap in invalid date existing in a field ?
All ideas will be appreciated.
The file has had some corrupted values in it. As I skip through the database, sometimes the system will throw an error because one of the date fields values is somehow wrong.
The error is ADSCDX 5095 : Cannot convert to a Juliene date. It sees the date time stamp as a negative value but I can't see anything in the field.
So, here is my question. How can I test the dates in record fields to prevent the error from occurring. In other words, if the date is invalid ( or corrupted ), I want to place a default value in it's place.
The line of code failing:
AADD( aPMitems, { oPMtable:PMSCOD, dBaseD, 0, oPmtable:recno() } )
The file is oPMtable. dBaseD is simply CTOD( "01/01/80" ). The problem is not here, but when database.prg skips to the record, apparently it does not like one of the values in the date fields it sees. It fails at line 1048:
for n = 1 to Len( ::aBuffer )
::aBuffer[ n ] = ( ::cAlias )->( FieldGet( n ) )
next
SO ... Any thoughts on a strategy here to trap in invalid date existing in a field ?
All ideas will be appreciated.