ILE COBOL Language Reference

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


FIND-DURATION

The FIND-DURATION function is used to calculate a duration between:

The FIND-DURATION function returns an integer in the form of complete units of the specified duration. Any rounding is done downwards. The calculation of durations includes microseconds.

The function type is integer.

The function result is a nine-digit integer. If the function result is larger than 9 digits (999,999,999), a machine check occurs.

Format
 
>>-FUNCTION FIND-DURATION--(--argument-1--argument-2--argument-3--)-><
 
 

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

Argument-1 is subtracted from argument-2. The value returned is the number of complete units of argument-3. If argument-1 is later than argument-2, the result is negative. If argument-1 is earlier than argument-2, the result is positive.

argument-3
Is a keyword that represents a duration. The valid duration keywords are:

In order to determine the valid duration keywords, the following rules apply:

  1. If argument-1 or argument-2 is a date item, the duration specified must be consistent with a date.
  2. If argument-1 or argument-2 is a time item, the duration specified must be consistent with a time.
  3. If the returned value is not an integer, it is truncated. For example, the duration between March 17, 1997 and May 2, 1997 is 1.5 months. Since FIND-DURATION only returns an integer the .5 would be truncated, and the actual value returned would be 1.

Related Information


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