Implicit date comparisons and conversions are made by the compiler if the two operands have the DATE attribute. The DATE attribute specifies that a variable, argument, or returned value holds a date with a specified pattern. millennium language extensions supports a number of date patterns as described in Understanding date patterns.
The DATE attribute is valid only with variables having one of the following sets of attributes:
The length or precision, n, must be a constant equal to the length of the date pattern or default pattern.
When the RESPECT compile-time option (discussed later in this chapter) has been specified, the DATE built-in function returns a value that has the attribute DATE('YYMMDD'). This allows DATE() to be assigned to a variable with the attribute DATE('YYMMDD') without an error message being generated. If DATE() is assigned to a variable not having the DATE attribute, however, an error message is generated.
Here are a few examples using the DATE attribute:
dcl gregorian_Date char(6) date;
dcl julian_Date pic'(5)9' date ('YYDDD');
dcl year fixed dec(2) date('YY');
The DATE attribute is useful even if you have no year 2000 problems in your applications. You can use it to manipulate differing dates as shown in these examples:
dcl gregorian_Date char(8) date ('YYYYMMDD');
dcl julian_Date pic'(7)9' date ('YYYYDDD');
if julian_Date > gregorian_Date then ...