Reference > Expressions > Built-in Functions > Date Functions > AddMonths

AddMonths

Returns the UTC date and time for the month that is the number of months specified earlier than or later than the specified date and time.

Syntax

AddMonths(numMonths, baseDateTime)

Enabled for

Search/Dashboard Yes
Business Rules Yes
Quick Actions Yes
Workflow Objects No
Reports No

Parameters

numMonths The number of intervals. If not specified, uses the default interval which is 0. Can be either a positive integer, to indicate months in the future, or a negative integer, to indicate months in the past.
baseDateTime (Optional) The base date for the function. If not specified, uses the default date which is the current date and time.

Returns

DateTime value in UTC time.

  • If the system has to display the return value, it implicitly converts it to text, thereby allowing the display format to change depending on your culture code. See Available Languages and Cultures for a list of the culture codes used by HEAT.
  • If the return value would not be a valid date, the function returns the last day of the month. For example, in the following function: $(AddMonths(4, mydate)), if the value of mydate is October 31, 2014, this function would have returned February 31, 2015, but because that is not a valid date, the function returns February 28, 2015 because that is the last day of the month.

Example

$(AddMonths(4))

If today is April 10, 2014, this function returns the DateTime value for August 10, 2014 at the same time of day.

 

$(AddMonths(3, mydate))

If the value of mydate is April 10, 2014, this function returns the DateTime value for 3 months later, which is July 10, 2014, at the same time of day.

 

$(AddMonths(-1, mydate))

If the value of mydate is April 10, 2014, this function returns the DateTime value for March 10, 2014 at the same time of day.