addYear function in the Factory
The addYear function adds a given number of years to a date attribute.
Parameters Parameter Description date The date attribute we want to add quarters to. The date parameter is mandatory. nyear The number of years to add to the chosen date attribute. The nyear parameter is mandatory. Date type valid formats (if the values aren’t this format, the function will return an error). 2019/10/12; 12/10/2019; 2019-10-12; 12-10-2019; 2019/Oct/12; 12/Oct/2019; 2019-Oct-12; 12-Oct-2019. Example The following example uses the Bike sales dataset. Description Screenshot In this example, we want to add two years to the Date attribute. We type the following formula in the addqyear attribute: and the attribute will be filled with the Date attribute’s values postponed by two years. The results are as follows: In row 1, the Date value 2013-11-26 becomes 2015-11-26 in the addyear attribute. In row 2, the Date value 2015-11-26 becomes 2017-11-26 in the addyear attribute.addYear(date, nyear)
addYear($"Date",2)