Example: DATEVAL
This example shows a case where it is better to leave
a field as a nondate, and use the DATEVAL
intrinsic
function in a comparison statement.
Assume that
a field Date-Copied
is
referenced many times in a program, but that most of the references
just move the value between records or reformat it for printing. Only
one reference relies on it to contain a date (for comparison with
another date). In this case, it is better to leave the field as a
nondate, and use the DATEVAL
intrinsic function in
the comparison statement. For example:
03 Date-Distributed Pic 9(6) Date Format yyxxxx.
03 Date-Copied Pic 9(6).
. . .
If Function DATEVAL(Date-Copied "YYXXXX") Less than Date-Distributed . . .
In this example, DATEVAL
converts Date-Copied
to
a date field so that the comparison will be meaningful.