$dateadd function
$dateadd(date,days,months,years)
The $dateadd function returns the date that is days, months, years after
date (or before, if any of them are negative). The date is returned
in the standard internal format yyyymmdd: 4-digit year, 2-digit month,
2-digit day of the month.
The days, months, years parameters are optional; you may leave them
empty if you don't need them. However, you must insert commas as necessary
to indicate which of the three fields you are using. Some examples:
- $dateadd(date,days) to add a number of days;
- $dateadd(date,,months) to add a number of months;
- $dateadd(date,,,years) to add a number of years;
- $dateadd(date,days,,years) to add a number of days and years.
Tip: To add or subtract days, months, or years from the current date,
you can use the $datenow function.
Windows Installer does not support symbolic functions; if you use this function
during an MSI build, you will get diagnostic message BLD:U0010
and the result is undefined.
Parameters
All parameters may contain symbolic references; these are resolved before the
function is applied. See Examples below.
- date
- Starting date in the format yyyymmdd.
- days
- Difference in days, either positive (for a later date) or negative (for
an earlier date). This parameter is optional.
- months
- Difference in months, either positive (for a later date) or negative (for
an earlier date). This parameter is optional.
- years
- Difference in years, either positive (for a later date) or negative (for
an earlier date). This parameter is optional.
Examples
Here are some usage examples for this function:
- <$dateadd(<BuildDate>, 30)>
-
Returns the date 30 days after the installer was built.
Note: BuildDate
is a standard variable. However, it is not saved in the installer's
database by default, so you must set its Save for Tarma attribute
to use it in the installer.
- <$dateadd(<BuildDate>,,6)>
- Returns the date six months after the installer was built.
- <$dateadd(<BuildDate>,1,,1)>
- Returns the date 1 year plus 1 day after the installer was built.
- <InstallDate> > <$dateadd(<BuildDate>,,6)>
- This is a conditional expression that returns True if the current installation
date is more than 6 months after the installer's build date. You can use
this type of condition, for example, to alert the user to possible new
software releases. InstallDate
is a standard variable.