Tech Tip: A tip for reading dates from 4D using Visual Basic via ODBC
PRODUCT: 4D | VERSION: 13.2 | PLATFORM: Mac & Win
Published On: January 24, 2013
Keep the following in mind when working with dates in 4D that will be accessible via ODBC to Visual Basic:
In 4D, null is valid for a date type.
In VB, null is not valid for a date type and the following error may be presented:
Conversion from type 'DBNull' to type 'String' is not valid |
In 4D, 0/0/0 is valid for a date type.
In VB, 0/0/0 is not valid for a date type and the following error may be presented:
Year, Month, and Day parameters describe an un-representable DateTime. |
In Visual Basic you can easily check for null values using code like the following:
If (IsDBNull(dbread.Item(0))) Then '''' do something for null values Else '''' do something for non null values End If |
However, I have not found a way in Visual Basic to check for or trap the error presented from 00/00/00 dates.
Therefore I suggest that the 4D Administrator take action to make sure that 00/00/00 dates do not exist in there data. This can be accomplished via a number of programming techniques. It may be worthwhile to also make sure that no null dates exist either.