Xbasic
ADDMONTHS Function
Syntax
Ending_Date as D = ADDMONTHS(D date, N months)
Arguments
- dateDate
The date that months will be added to.
- monthsDate
The number of months to add. Specifying a negative value will perform a month subtraction from the specified date.
Returns
- Ending_DateDate
The result of adding months to date.
Description
Adds a number of months to a date.
Discussion
ADDMONTHS() returns an Ending_Date equal to the specified Starting_Date plus the specified Number_Of_Months.
The ADDMONTHS() function adds the specified Number_Of_Months to the Starting_Date and then checks if the resulting date is valid. If the resulting date is not valid (e.g., 1-31-95 plus 1 month is 2-31-95), the highest valid date in that month (e.g., 2-28-95) is returned. Alpha Anywhere does recognize leap years.
Example
? ADDMONTHS({1-31-95},1) = {02/28/1995} ? ADDMONTHS({3-15-95},1) = {04/15/1995} ? ADDMONTHS({5-15-95},-2) = {03/15/1995}
See Also