About this article
DateSubtract() is a function that calculates a date based on another date. It subtracts days, weeks, months, quarters or years from the selected date.
Prerequisites
|
Syntax 1
Syntax | {{DateSubtract (Date, Number, Text)}} |
Input | DateTime, Units, UnitType |
Output | Date with Units subtracted, where Units are UnitType ("d", "M", "Q", "w", "y") |
|
Syntax 2
The syntax below can also be used. If the 'Text' variable is omitted then the Units are interpreted as days.
Syntax | {{DateSubtract (Date, Number)}} |
Input | DateTime, Units |
Output | Date with Units subtracted, where Units are Days ("d") |
Example 1
In the examples below 14 days, weeks, months, quarters or years are subtracted from Form.Date.
The value of Form.Date is "1 January 2022".
Description | Binding | Output |
Date - 14 days | {{DateSubtract(Form.Date, 14)}} |
2021-12-18 |
Date - 14 days | {{DateSubtract(Form.Date, 14, "d")}} |
2021-12-18 |
Date - 14 weeks | {{DateSubtract(Form.Date, 14, "w")}} |
2021-09-25 |
Date - 14 months | {{DateSubtract(Form.Date, 14, "M")}} |
2020-11-01 |
Date - 14 quarters | {{DateSubtract(Form.Date, 14, "Q")}} |
2018-07-01 |
Date - 14 years | {{DateSubtract(Form.Date, 14, "y")}} |
2008-01-01 |
Example 2
Using the DateSubtract() function in combination with FormatDateTime() to apply formatting to the output.
The value of Form.Date is "1 January 2022".
Description | Binding | Output |
Date - 14 days | {{FormatDateTime(DateSubtract(Form.Date, 14, "d"), "d MMMM yyyy", "en-US")}} |
18 December 2021 |
Related articles
Comments
0 comments
Article is closed for comments.