A year-first date field is a date field whose DATE FORMAT specification consists of YY or YYYY, followed by one or more Xs. 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 Xs preceding YY or YYYY.
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.
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.
If your version of DFSORT (or equivalent) has the appropriate capabilities, year-last dates are supported as windowed keys in SORT or MERGE statements. Apart from sort and merge operations, 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.
Example: comparing year-first date fields
related concepts
Compatible dates
related tasks
Sorting and merging by date
Using other date formats