Skip to main content

Datetime: Date Subtract

Shift a Date or DateTime backward by amount × unit. Negative amount values shift forwards (equivalent to Datetime::DateAdd with the absolute value).

Same unit / input-type rules as Datetime::DateAdd: sub-day units only work on DateTime; date-only units work on both Date and DateTime.

Example
amount=7, unit=Day → Date(2024-06-15) → Date(2024-06-08)
amount=1, unit=Year → Date(2024-06-15) → Date(2023-06-15)
amount=30, unit=Minute → DateTime(2024-06-15T14:30Z) → DateTime(2024-06-15T14:00Z)

Parameters​

Amountrequired

Number of units to subtract. Defaults to 1. Negative values shift forwards.

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.