Supported RPG Features

The ADDDUR opcode adds a numeric duration to a date, time, or timestamp field. It is a fixed-format C-spec operation:

C     factor1       ADDDUR    amount:*Code  result

Factor 1 (the source) is optional; when blank, the result field is updated in-place.

Duration Code Abbreviation Applies to
*DAYS *D DATE, TIMESTAMP
*MONTHS *M DATE, TIMESTAMP
*YEARS *Y DATE, TIMESTAMP
*HOURS *H TIME, TIMESTAMP
*MINUTES *MN TIME, TIMESTAMP
*SECONDS *S TIME, TIMESTAMP
*MSECONDS *MS TIMESTAMP only (microseconds)

Examples:

C     startDate     ADDDUR    90:*DAYS      endDate        // add 90 days
C     endDate       ADDDUR    2:*MONTHS     endDate        // add 2 months in-place
C     endDate       ADDDUR    1:*YEARS      endDate        // add 1 year in-place

The (E) operation extender traps calculation errors instead of letting them halt the program: on failure %ERROR is set *ON and %STATUS holds the status code (cleared at the start of the next (E) operation). Dates and timestamps support years 0001 - 9999; a result outside that range is a date overflow, reported as %STATUS 00113. Without (E) the error propagates.

C     workDate      ADDDUR(E) 99999:*YEARS  workDate
C                   IF        %ERROR                      // *ON: overflow trapped
C                   ...                                   // %STATUS = 00113