addmonths - script and chart function
This function returns the date occurring n months after startdate or, if n is negative, the date occurring n months before startdate.
Syntax:
AddMonths(startdate, n , [ , mode])
Return data type: dual
The AddMonths function returns a dual value with both the string and the number value. The function takes the numeric value of the input expression and generates a string representing the number. The string is displayed, whereas the numeric value is used for all numerical calculations and sorting.
Arguments:
Argument | Description |
---|---|
startdate | The start date as a time stamp, for example '2012-10-12'. |
n | Number of months as a positive or negative integer. |
mode | Specifies if the month is added relative to the beginning or to the end of the month. Default mode is 0 for additions relative to the beginning of the month. Set mode to 1 for additions relative to the end of the month. When mode is set to 1 and the input date is the 28th or above, the function checks how many days are left to reach the end of the month on the startdate. The same number of days to reach the end of the month are set on the date returned. |
Did this page help you?
If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!