Previous Topic: Divide with Remainder

Next Topic: Elapsed Time

Duration

The *DURATION built-in function calculates the elapsed time between a beginning date and an ending date.

Note: You should check the return code set by this function in order to catch any errors encountered. This function is the converse of the *DATE INCREMENT built-in function.

The *DURATION built-in function performs the operation:

*Duration = *Date1 - *Date2

The result is positive if *Date1 is after *Date2; it is negative if *Date1 is before *Date2.

There are eight parameters for this function type:

Note: The *Date list, *Excluded days of week, and *Select days/dates parameters affect only days/dates after the beginning date. If the ending date is before the beginning date, these parameters affect only days/dates after the ending date.

For more information on the selection input parameters, see the Selection Parameters for Date Built-In Functions topic in the *DATE DETAILS built-in function description.

The possible values for *Duration type and the effect each has on the meaning of *Duration are shown in the following table.

*Duration Type Values

Effect on the *Duration Parameter

*YEARS

The result is given as a number of full years; partial years are ignored.

*MONTHS

The result is given as a number of full months; partial months are ignored.

*YYMM

The result is given as a number of years and full months in YYMM format; partial months are ignored. For example, 1011 means 10 years and 11 months; 1100 means exactly 11 years.

*YYMMDD

The result is given as a number of years, months, and days in YYMMDD format. For example, 100923 means 10 years, 9 months, and 23 days; 110000 means exactly 11 years.

*DAYS

The result is the number of selected days. This is the default.