DIFF_DATE

Script Function: Determines the difference between two date entries in days.

Syntax

DIFF_DATE ([Date Format:]Date1, [Date Format:]Date2)

Syntax

Description/Format

Date1
and

Date2

Date in YYMMDD or YYYYMMDD format

Format: script literal or script variable

(Optional) You can specify a different date format: enter the desired date format, a separator (: or ;) and the date.


Return code

Number of days lying between the two indicated dates

This script function determines the distance between Date1 and Date2 in days. It is possible for Date2 to be before or after Date1.

When defining dates, Date Format is optional. If no particular Date Format has been defined, the date must be entered in the format "YYMMDD" or "YYYYMMDD". You can use a colon or semicolon as a separator between Date Format and date.

Example

The first example calculates the difference between date entries. The dates use the default format "YYMMDD" and "YYYYMMDD". The result "1" is output in the report.

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

In the second example, the date entries are assigned to the script variables. The script function is called with this script variable. Because the data do not use a default format, the special date format must also be used with the script variables. The result "366" is output in the report.

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

The third example has the same result as the second example. The difference here is that the script variables are assigned a date format and a 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