Consultor Eletrônico



Kbase P186037: Attempting to pass a datetime outside the range allowed by Microsoft datetime field generates error
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   15/04/2011
Status: Unverified

SYMPTOM(s):

Attempting to pass a datetime outside the range allowed by Microsoft datetime field generates error 22008:[Microsoft][ODBC SQL Server Driver]Datetime field overflow

No errors for dates with years between 1753 and 9999

FACT(s) (Environment):

Windows
MS SQL DataServer

CAUSE:

This behavior is due to specific defined date range limits of Microsoft SQL Server.

FIX:

Avoid passing an invalid date to the Microsoft SQL database by programmatically testing date values.

Example:
CREATE sports2000.spt1.
ASSIGN spt1.f1 = datetime("01/01/1752 23:59:59.999").
IF year(spt1.f1) < 1753 THEN
DO:
MESSAGE "Your date is too low."
VIEW-AS ALERT-BOX INFO BUTTONS OK.
RETURN.
END.
BUFFER-COPY sports2000.spt1 TO mssld.t1 NO-ERROR.

In the above example the sports2000 is an OpenEdge database.
The f1 is an OpenEdge datatime field.
The mssld is an MSSQL dataserver connection which has a corresponding f1 Microsoft datetime field.