DATEADD
Adds a number of days, months, or years to a date
Usage
DATEADD(date, number, [unit])
Parameters
date |
(Required) The date to which to add days, months, or years |
number |
(Required) The number to add to the date. It can be positive or negative |
unit |
The unit of time to add (“days”, “months”, or “years”). Uses “days” if not specified |
Examples
More information
The unit
parameter, if provided, must be one of ‘days’, ‘months’, or ‘years’.
If you add a negative number, you will subtract from the date.
Be cautious with adding months, as it considers the month boundaries. For instance, adding one month to January 31st will result in the last day of February.
Reminders
A text containing a date is not handled as a date. To have an actual date:
- use the
@DATE_QUESTION
to set the variable - use a function that converts to a date:
DATEVALUE(text_date)
- use a function that returns a date:
TODAY()
orDATE(year, month, day)
A text containing digits is not handled as a number. To have an actual number:
- use the
@NUMBER_QUESTION
to set the variable - write a numeric value directly in the code without quotes, ex:
age >= 18
- use a function which converts to a number:
NUMBER(text_containing_numbers)
- use a function which returns a number:
FIND("world", "hello everybody")