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
| Parameter | Description | Format |
|---|---|---|
| Date1, Date2 |
Specify the dates to calculate the difference between. Note: Date2 can be before or after Date1.Specify the date format when you use a format other than YYMMDD or YYYYMMDD. Separate the date format and the date with a colon or semicolon. For more information, see Date, Time and Period Formats in Scripts. |
Script literal or script variable |
Return Codes
The DIFF_DATE function returns the difference between the two dates in days.
Examples
The following example calculates the difference between two dates that 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 and passed to the script function. 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, but the script variables are directly assigned a date format. Therefore, the date formats do not need to be specified when calling DIFF_DATE.
: SET &DATE1# = "DD-MM-YYYY:01-01-2000"
: SET &DATE2# = "DDMMYYYY:01012001"
: SET &DIFF# = DIFF_DATE (&DATE1#, &DATE2# )
: PRINT &DIFF#