Function Updated 19 Oct 2026
addMonths(datetime, months)
Adding a number of months (positive or negative value) to a specified date.
Parameters
datetimedatetimerequiredDate on which to add months to.
monthsnumberrequiredHow many months to add (whole number, may be negative). A decimal number gives null instead of a date.
Returns
A new date; the input date is not changed. Returns null if the input is not a valid date or the number is not a whole number.
Example
Mixed HTML (or any text file) with inline JavaScript between hash signs.
#{
var dt = new Date(); // Create new date and time object
write("Before: ");
write(format(dt, "dd. MMM yyyy")); // output time
write("<br>");
dt = docly.addMonths(dt, 3); // Add months
write("After:");
write(format(dt, "dd. MMM yyyy")); // output time
}#The template above produces this output:
Before: 01. Nov 2026<br>After:01. Feb 2027