DATEDIFF – Calculate the difference between two dates
This function returns the difference in days between two dates.
DATEDIFF(<date1>,<date2>)
Where:
<date1>
- The date from which to subtract.
<date2>
- The date to be subtracted.
<date2>
is subtracted from <date1>
. If
<date2>
is greater than <date1>
, the
result will be negative.
Both dates must be in the format YYMMDD. Use the DATEFORM
function to convert the format, if needed.
The following command returns
7992:
DATEDIFF("211118","000101")
The following command returns the number of days since day 1 of January
2000:
DATEDIFF("=","000101")
Consider that:
- The equal sign (=) can be used in place of a date to indicate the current date.
- +n can be used in place of a date to indicate n days after the current date.
- -n can be used in place of a date to indicate n days before the current date.
- In all cases the relative dates must be contained in quotes for function calls.