addDays(date, days) Last updated: 30. 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 datetime

Date object on which to add days to.

days number

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> 05. Jun 2026 20:50<br>
<b>After:</b> 11. Jun 2026 01:38