| ## PL/I 9's complement

You can use a decimal calculator to convert from and to 9's complement dates:

                                                     9's comp | regular
    Dcl Y2K_BEG_9COMP_DATE Char(6)            Value (498768); | 501231
    Dcl Y2K_END_9COMP_DATE Char(6)            Value (489898); | 510101
    Dcl Y2K_20_CENT_END_9COMP_DATE Char(6)    Value (008768); | 991231
    Dcl Y2K_20_CENT_END_PLUS_1_9COMP Char(6)  Value (008767); | 991232
    Dcl Y2K_20_CENT_BEG_9COMP_DATE Char(6)    Value (999898); | 000101
    Dcl Y2K_20_CENT_BEG_MINUS_1_9COMP Char(6) Value (999899); | 000100

To convert a regular date to a 9's complement date:

      DATE_9COMP = 999999 - DATE_REG.

To convert a 9's complement date to a regular date:

      DATE_REG = 999999 - DATE_9COMP.

(Of course, the variables used in arithmetic must be numeric.)

The sum of a regular date and its 9's complement will always equal all 9s.
(Thanks for Bob King for this code.)

©1997 IBM Corporation