IBM Extension
IBM Extension

FIND-DURATION

The FIND-DURATION function is used to calculate a duration between:
  • Two dates
  • A date and a timestamp
  • Two times
  • A time and a timestamp
  • Two timestamps.

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.
Read syntax diagramSkip visual syntax diagram
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:
  • YEARS
  • MONTHS
  • DAYS
  • HOURS
  • MINUTES
  • SECONDS
  • MICROSECONDS
  • Start of changePICOSECONDSEnd of change
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.
  4. Start of changePICOSECONDS duration can only be requested when argument-1 and argument-2 are timestamp items.End of change
Related Information
End of IBM Extension
End of IBM Extension