years(nYears: Number): Period
Creates a Period value from the provided number of years.
The function applies the period function to the input value.
Introduced in DataWeave version 2.4.0.
Parameters
| Name | Description |
|---|---|
|
A whole number for the number of years. A positive or negative number is valid. |
Example
This example shows how years behaves with different inputs.
It adds a year to a DateTime value, and it converts the whole
number 4 into a number of years in the Period format (P4Y).
Notice that years(-1) + years(2) returns the number of months.