ILE COBOL Language Reference

+-------------------------------IBM Extension--------------------------------+


ADD-DURATION

The ADD-DURATION function adds a duration to a date, time, or timestamp item, and returns the modified item.

The function type is date-time.

The length of the returned value depends on the length of the date, time, or timestamp item specified in argument-1.

If a duration is added to a date item, the date returned must fall within a certain range:

If a duration is added to a 2-digit date item, the range is the same as for a 4-digit year, but the year in the value returned is truncated to 2 digits.

Format
 
                                         .------------------------.
                                         V                        |
>>-FUNCTION ADD-DURATION--(--argument-1----argument-2--argument-3-+--)-><
 
 

argument-1
Must be date, time, or timestamp data item.

Argument-1 is a data item containing a value to which a duration is added. The duration is specified in argument-2 and argument-3.

argument-2
Argument-2 is a keyword that represents a duration. The valid duration keywords are:

The duration keyword must be consistent with argument-1. For example, the duration keywords most obey the following rules:

  1. YEARS, MONTHS, and DAYS can only be added to a date or timestamp item.
  2. HOURS, MINUTES, SECONDS, and MICROSECONDS can only be added to a time or timestamp item.
argument-3
Must be an integer arithmetic expression. Argument-3 is the number of units of the duration, as specified in argument-2, that are to be added to argument-1.

Argument-3 can be a negative integer, but the function only takes its absolute value. If argument-3 is longer than 9 digits, it is truncated.

Argument-2 and argument-3 can be repeated. There should be no duplicate argument-2 in one intrinsic function.

If a duration is added to a date, and the result is invalid, the date is adjusted. For example, if a duration of 1 month is added to the date March 31, 1997, the result would be the invalid date April 31, 1997. This date would be adjusted to the valid date April 30, 1997.

Related Information


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]