DIFF_DATE

Use the DIFF_DATE script function to calculate the difference between two dates in days.

Syntax

DIFF_DATE ([DateFormat:]Date1, [DateFormat:]Date2)

Parameters

Examples

These examples calculate the difference between two dates, and print the result in the activation report.

The dates specified in the following script lie 1 day apart. The dates use the default YYMMDD and YYYYMMDD formats, so the script does not need to specify any date formats.

:SET &DIFF# = DIFF_DATE("000330","20000331")
:
PRINT &DIFF#

Line in the activation report:

2019-03-28 12:22:01 - U00020408 000000001

In the following example, the dates are assigned to script variables. The DIFF_DATE script function is called with the script variables. Since the dates do not use the default date formats, the script must specify the date formats.

:SET &DATE1# = "01-01-2000"
:
SET &DATE2# = "01012001"
:
SET &DIFF# = DIFF_DATE("DD-MM-YYYY:&DATE1#", "DDMMYYYY;&DATE2#")
:
PRINT &DIFF#

Line in the activation report:

2019-03-28 12:28:44 - U00020408 000000366

The following example returns the same result as the previous example. The difference is that the script variables are assigned a date format. Therefore, the date formats do not need to be specified when you call DIFF_DATE.

:SET &DATE1# = "DD-MM-YYYY:01-01-2000"
:
SET &DATE2# = "DDMMYYYY:01012001"
:
SET &DIFF# = DIFF_DATE(&DATE1#, &DATE2#)
:
PRINT &DIFF#

See also:

seealso

Script Date and Time Functions

Date, Time and Period Formats in Scripts