Using year-first, year-only, and year-last date fields
When you compare two date fields of either year-first or year-only types, the two dates must be compatible; that is, they must have the same number of nonyear characters. The number of digits for the year component need not be the same.
About this task
A year-first date
field is a date field whose DATE FORMAT
specification
consists of YY
or YYYY
, followed
by one or more X
s. The date format of a year-only date
field has just the YY
or YYYY
. A year-last date
field is a date field whose DATE FORMAT
clause specifies
one or more X
s preceding YY
or YYYY
.
Year-last date formats are commonly used to display dates, but are less useful computationally because the year, which is the most significant part of the date, is in the least significant position of the date representation.
Functional support for year-last date fields is limited to equal or unequal comparisons and certain kinds of assignment. The operands must be either dates with identical (year-last) date formats, or a date and a nondate. The compiler does not provide automatic windowing for operations on year-last dates. When an unsupported usage (such as arithmetic on year-last dates) occurs, the compiler provides an error-level message.
If you need more general date-processing capability for year-last dates, you should isolate and operate on the year part of the date.