Skip to main content

Datetime: Date Add

Shift a Date or DateTime forward by amount × unit. Negative amount values shift backwards (equivalent to Datetime::DateSubtract with the absolute value).

Sub-day units (Microsecond, Millisecond, Second, Minute, Hour) only work on DateTime inputs — applying them to a bare Date fails the step. Date-only units (Day, Week, Month, Year) work on both.

Example
amount=7, unit=Day → Date(2024-06-15) → Date(2024-06-22)
amount=1, unit=Month → Date(2024-01-31) → Date(2024-02-29)
amount=2, unit=Hour → DateTime(2024-06-15T14:30Z) → DateTime(2024-06-15T16:30Z)

Parameters

AmountREQUIRED

Number of units to add. Defaults to 1. Negative values shift backwards.

UnitREQUIRED

Time unit applied to amount. One of Microsecond, Millisecond, Second, Minute, Hour, Day, Week, Month, Year. Defaults to Day.

Input

DateREQUIRED
A Date or DateTime value to shift.

Output

Date

The shifted value, same type as the input.