DATEPERIOD

Purpose:

Calculates the difference between two date series in years, months and days.

Syntax:

DATEPERIOD(date1, date2)

(y, m, d) = DATEPERIOD(date1, date2)

date1

-

A series of Julian integer dates, the end dates.

date2

-

Optional. A series of Julian integer dates, the start dates. Defaults to an empty series.

Returns:

The elapsed period as an N x 3 series of years, months, days.

 

(y, m, d) = DATEPERIOD(date1, date) returns the values in separate variables.

 

If only one date series is specified, the periods are computed on the two-point difference of each date value.

Example:

W1: ymd2date(2010, 11, 12)

W2: ymd2date(2020, 10, 20)

W3: dateperiod(w2, w1)

W4: dateoffset(w1, w3)

 

W1 contains the date:

 

11/12/2010

 

W2 contains the date:

 

10/20/2020

 

W4 calculates the end date in W2 by adding the time offset in W3 to the start date in W1.

Example:

W1: ymd2date(2010, 11, 12)

W2: ymd2date(2020, 10, 20)

W3: dateperiod(w1, w2)

W4: dateoffset(w2, w3)

 

Same as the first example, except the start and end dates are swapped. The result is a negative period, -9 years, -11 months and -8 days.

 

W4 calculates the end date in W1 by subtracting the time offset in W3 from the start date in W2.

Remarks:

DATEPERIOD computes the difference between two date series with the result in periods of years, months and days.

 

If only one date series is provided, the two-point period difference between subsequent date values is computed.

 

A date period is measured in years, months and days.

 

A date duration is measured in seconds.

 

See DATEDURATION  to compute the time difference in seconds.

See Also:

DATE2YMD

DATEDURATION

DATEOFFSET

DTDIFF

DTDURATION

DTOFFSET

DTPERIOD

YMDHMS2DT