Using DATEVAL
You can use the DATEVAL
intrinsic function
to convert a nondate to a date field, so that COBOL will apply the
relevant date processing to the field.
About this task
The first argument in the function is the nondate to
be converted, and the second argument specifies the date format. The
second argument is a literal string with a specification similar to
that of the date pattern in the DATE FORMAT
clause.
In most cases, the compiler makes the correct assumption about the interpretation of a nondate but accompanies this assumption with a warning-level diagnostic message. This message typically happens when a windowed date is compared with a literal:
03 When-Made Pic x(6) Date Format yyxxxx.
. . .
If When-Made = "850701" Perform Warranty-Check.
The literal is assumed to be a compatible windowed
date but with a century window of 1900-1999, thus representing July
15, 1985. You can use the DATEVAL
intrinsic function
to make the year of the literal date explicit and eliminate the warning
message:
If When-Made = Function Dateval("19850701" "YYYYXXXX")
Perform Warranty-Check.