Previous Topic: DATECHGNext Topic: DATEEXT


DATEDIF

Purpose

Returns the number of days between two specified dates.

Syntax

►►─┬─ DATEDIF ──┬─ ( gregorian-date-1, gregorian-date-2 ) ────────────────────►◄
   └─ DATEDIFX ─┘

Parameters

DATEDIF/DATEDIFX

Invokes the date difference function. DATEDIFX operates on values containing the century portion of the date.

gregorian-date1

Specifies the date, in Gregorian format, from which the second date is subtracted.

gregorian-date2

Specifies the date, also in Gregorian format, that is subtracted from the first date.

Gregorian-date1 and gregorian-date2 can be:

Example 1

In the following example, the date difference function is used to find the number of days between January 28, 1978 and August 11, 1975:

Statement:
    MOVE DATEDIF(780128,750811) TO WK-RESULT.
Returned value: 901

Note that if the dates were supplied in reverse order, the value -901 would have been returned.

Example 2

In this example, the date difference function is used to find the number of days between January 6, 2000 and December 25, 1999, specifying the century portion of the year:

Statement:
    MOVE DATEDIFX(20000106,19991225) TO WK-RESULT.
Returned value: 12

Again, if the dates were supplied in reverse order, the value -901 would have been returned.