ADD_MONTHS Function
Description: Ages the date field by the specified number of months. The months specified are added to the source date provided. If the number of months 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_MONTHS function rolls forward or backward the specified number of months based on the year. It takes leap year and the number of days in a month into consideration when aging the date. Aging of the date must result in a valid date. This function will cause the month and may cause the year to change. If aging a date results in a day that is beyond the number of days in the month, the day is set to the last day of the aged month; and the month is not allowed to roll beyond the requested increment.
Parameters: String, Integer
- Source date: The string containing the source date value.
- Months: The number of months to age. Specify the number of months to add or specify a negative value to subtract months.
Return: String containing the result date.
Syntax: ADD_MONTHS (<source date>,<months>)
Example: Set the birth date to two months before the original birth date:
DE("Birth Date").setValue
( ADD_MONTHS( DE("Birth Date").getOriginalValue( ), -2) );
{{export-indexterm primary="ADD_MONTHS function"/}}