Arithmetic with Dates

If an arithmetic expression subtracts one date from another (i.e., both operands are of data type DATE), the result is a number representing the number of days between the two dates.

For example, consider the following expressions, in which the variables Date1 (value 19990923) and Date2 (value 19980923) are of the data type DATE:

Date1 - Date2

Is 19990923 - 19980923 but evaluates to 365 (not 10,000) because the expression is really 23SEP1999 - 23SEP1998.

If you add (subtract) a value that is not a date to (from) a date, the result is a date equal to the date operand plus (minus) the number of days indicated by the non-date operand.

Date1 - 100

Is 19990923 - 100, but evaluates to 19990615 (15Jun1999 - not 19990823)

Date1 +100

Is 19990923 + 100, but evaluates to 20000101 (1Jan2000- not 19991023)

If you use dates in any other type of operation, the dates are treated as numbers:

Date1/100

Is 19990923/100, and evaluates to 199909.

The software provides a number of built-in functions to perform date and time arithmetic (e.g., $addyears, $addmonths, $addminutes, $addhours).