Comparisons
A date field can be compared to a date constant or another date field with the same number of non-year (x) digits. Table 1 shows the type of field-to-field and field-to-constant comparisons you can use. The fields shown for any type of date (for example, yyx and xyy) can be compared to any other fields shown for that type of date or to the Y constant shown for that type of date.
Permissible Comparisons for Dates
Type of Date |
Fields (m,f) | Y Constant | |
---|---|---|---|
yyx and xyy | 3,Y2T |
2,Y2U |
Y'yyx' |
yyxx and xxyy | 4,Y2T |
3,Y2V |
Y'yyxx' |
yyxxx and xxxyy | 5,Y2T |
3,Y2U |
Y'yyxxx' |
yyxxxx and xxxxyy | 6,Y2T |
4,Y2V |
Y'yyxxxx' |
yy | 2,Y2C |
2,Y2Z |
Y'yy' |
- Y'DATE1' generates a Y constant for the current date in the form Y'yymmdd'
- Y'DATE1'+d generates a Y constant for the current date plus d days in the form Y'yymmdd'
- Y'DATE1'-d generates a Y constant for the current date minus d days in the form Y'yymmdd'
- Y'DATE2' generates a Y constant for the current date in the form Y'yymm'
- Y'DATE2'+m generates a Y constant for the current date plus m months in the form Y'yymm'
- Y'DATE2'-m generates a Y constant for the current date minus m months in the form Y'yymm'
- Y'DATE3' generates a Y constant for the current date in the form Y'yyddd'
- Y'DATE3'+d generates a Y constant for the current date plus d days in the form Y'yyddd'
- Y'DATE3'-d generates a Y constant for the current date minus d days in the form Y'yyddd'.
You must use the same number of digits in a Y constant as the type of date; leading zeros must be specified (for example, for Y'yymm', use Y'0001' for January 2000 and Y'0501' for January 2005).
- Y'0...0' (CH/ZD/PD zeros) and Y'9...9' (CH/ZD/PD nines) can be used with Y2T, Y2U, Y2V, Y2W, Y2X and Y2Y dates. You must use the same number of digits as the type of date (for example, Y'000' for yyq or qyy, Y'0000' for yymm or mmyy, and so forth).
- Y'LOW' (BI zeros), Y'BLANKS' (blanks) and Y'HIGH' (BI ones) can be used with Y2T, Y2W and Y2S dates.