ADD_YEARS Function


Description: Ages the date field by the specified number of years. The years specified are added to the source date provided. If the number of years is a negative number, the value is subtracted. The result is the actual calculated date.

This function is only valid for data elements with a processing type of date. The ADD_YEARS function rolls forward or backward the specified number of years based on the year. It takes leap year into consideration when aging the date. Aging of the date must result in a valid date. This function will cause the year to change, but will not change the month. The only case where the day will change is when the original date was February 29 (leap year) and the resulting year is not a leap year. In this case, the day will be set to February 28. ADD_YEARS is not reversible.

Parameters: String, Integer

  • Source date: The string containing the source date value.
  • Years: The number of years to age. Specify the number of years to add or specify a negative value to subtract years.

Return: String containing the result date.

Syntax: ADD_YEARS (<source date>,<years>)

Example: Set the hire date to five years before the original hire date:

DE("Hire Date").setValue
( ADD_YEARS( DE("Hire Date").getOriginalValue( ), -5) ); 

{{export-indexterm primary="ADD_YEARS function"/}}

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*

BMC AMI DevX Workbench for Eclipse 23.01