Rational Developer for System z
PL/I for Windows, Version 8.0, Programming Guide

Implicit date comparisons

The DATE attribute causes implicit commoning when two variables declared with the DATE attribute are compared. Comparisons where only one variable has the DATE attribute are flagged, and the other comparand is generally treated as if it had the same DATE attribute, although some exceptions apply which are discussed later.

Implicit commoning means that the compiler generates code to convert the dates to a common, comparable representation. This process converts 2-digit years using the window you specify in the WINDOW compile-time option.

In the following code fragment, if the DATE attribute is honored, then the comparison in the second display statement is 'windowed'. This means that if the window started at 1900, the comparison would return false. However, if the window started at 1950, the comparison would return true.

    dcl a   pic'(6)9' date;
    dcl b   pic'(6)9' def(a);
    dcl c   pic'(6)9' date;
    dcl d   pic'(6)9' def(c);

    b = '670101';
    d = '010101';

    display( b || ' < ' || d || ' ?' );
    display( a < c );

Date comparisons can also occur in the following places:

Comparing dates with like patterns

The compiler does not generate any special code to compare dates with identical patterns under the following conditions:

Comparing dates with differing patterns

For comparisons involving dates with unlike patterns, the compiler generates code to convert the dates to a common comparable representation. Once the conversion has taken place, the compiler compares the two values.

Comparisons involving the DATE attribute and a literal

If you are making comparisons in which one comparand has the DATE attribute and the other is a literal, the compiler issues a W-level message. Further compiler action depends on the value of the literal as follows:

  dcl start_date char(6) date;
  if start_date >= '' then /* no windowing */
  ...
  if start_date >= '851003' then /* windowed */
  ...

Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)