Rational Developer for System z
COBOL for Windows, Version 7.5, Programming Guide


Using year-first, year-only, and year-last date fields

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.

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
Using other date formats


Terms of use | Feedback

Copyright IBM Corporation 1996, 2008.
This information center is powered by Eclipse technology. (http://www.eclipse.org)