addDays(date, days) Last updated: 01. May 2026

Adding a number of days (positive or negative value) to a specified date.

See also: Compare date field with todays date Get todays date SetCulture date og number format

Parameters

Name Type Description
date Date and time object Date object on which to add days to.
days number (int or float) How many days to add to specified date.

Returns

A modified date, does not modify input date.

Example

Code example (#JS)

#JS is mixed HTML (or other text file) with inline JavaScript with # starting and ending each inline statement.
#{
    var before = new Date(); // Create new date object
    var after = docly.addDays(before, 5.2); // Add 5.2 days
}#
<b>Before:</b> #docly.format(before, "dd. MMM yyyy HH:mm")#<br>
<b>After:</b> #docly.format(after, "dd. MMM yyyy HH:mm")#

Output

The #JS code above produces the output shown below:
<b>Before:</b> 08. May 2026 14:48<br>
<b>After:</b> 13. May 2026 19:36