addmonths Salesforce | Salesforce Formula Add Months to Date

Do you face any challenges where you want to add specific months to date in Salesforce? You can create Salesforce formula add months to date using addmonths function.

In this Salesforce tutorial, I will explain the add months function in Salesforce with its syntax and examples. I will also show you step-by-step how to create a formula to add months to a date in Salesforce.

addmonths Salesforce

The Salesforce ADDMONTHS is one of the Salesforce DATETIME functions that is used to perform calculations with date and time data. The ADDMONTHS function in Salesforce is used to add or subtract a specified number of months to a given date or datetime value.

You can use this function when you want to predict future dates, handle subscription renewals, or figure out when things will be delivered. Moreover, the syntax of the Salesforce ADDMONTHS function is as given below:

ADDMONTHS(date,num)

Here:

  • date: The date is the parameter that specifies the date value or datetime value to which you want to add months.
  • num: The num parameter specifies the number of months you want to add or subtract from the date or date/time value.

Return: It returns the date with a certain number of months before or after a given date. If the given datevalue -> last day of month -> result is last day of the month. Otherwise, the result will have the same day as the given date.

Furthermore, to understand the addmonths function in Salesforce, let’s see some of the examples given in the table below. The Input Field column shows the date or date/time expression entered by the user, and the Return column displays the output returned by the ADDMONTHS function in Salesforce.

See also  Salesforce Last Activity Date Formula
Input FieldOutput of ADDMONTHS() Function
5/17/2023If added 2 months, result = 7/17/2023
5/17/2023If subtracted 2 months result = 3/17/2023
10/27/2023, 12:46 AMIf added 5 months result = 3/27/2023, 12:46 AM
10/27/2023, 12:46 AMIf subtracted 5 months result = 5/27/2023, 12:46 AM
10/31/2023If added 1 month result = 10/30/2023. Because 10/31/2023 is the last day of the month, it will return to the last day of the month of the resultant month. In this case, the result month’s last date is 10/30/2023; therefore, the result is 30/10/2023.

Salesforce Formula Add Months to Date

Below are the steps to add month to date in Salesforce using the addmonth function in Salesforce.

1. Go to the Setup and click on the Object Manager tab on the Nav Bar. Then, search for the Object for which you want to add month-to-date in Salesforce.

How to Add 1 Month to Date in Salesforce Lightning Example

2. Click on Fields & Relationships in the left-hand menu of the object page and click on the New button to create a new field.

Add 1 Month to Date in Salesforce Lightning

3. Choose the type of the Formula field as you want to create the formula that adds the month to the date. After that, click on the Next button.

Add 1 Month to Date in Salesforce Lightning Example

4. Enter the label for the field and the Field name will get populated automatically. For example, I enter Field Label to Upcoming Campaign. Then, choose the Date as the Formula Return Type. Then Click on the Next button.

Add 1 Month to Date Example in Salesforce Lightning

5. Enter the formula for adding month to date. The following are the steps to do so:

  • From the left-aligned Functions List, select the ADDMONTHS function. Next, click on the Insert Selected Function button.
  • Choose the field that you want to pass to the function and add 1 month to the date. Click on the Insert Field button to do that. Here I pass the Created Date field to the function.
  • Replace the num parameter with the number you want to add to the month of the date. Here, I set the number 1.
See also  Salesforce Formula Add Year to Date

Then, click on the Check Syntax button to check the errors, then add the Description and Help Text if you want, and also Treat Blank Fields As Blanks. After that, click on the Next button.

How to Add 1 Month to Date in Salesforce Lightning

6. Set up the field level security; choose the Profile to which you want to grant edit access to this field by checking and unchecking the Visible checkbox. Then, click on the Next button.

How to Add 1 Month to Date in Salesforce

7. Now, choose the Page Layouts on which you want this field to appear. If you don’t select any of the page layout fields, it will not appear on that page. Then, click on the Save button.

How to Add 1 Month to Date in Salesforce example

Once the formula is applied to the field, open the Campaign object and select any campaign, move to the Details section, and here you will get the newly created field that adds 1 month to the date.

Add 1 Month to Date in Salesforce

Conclusion

I hope you have learned about the addmonth function in Salesforce. I have explained step-by-step how to create the formula to add a month to the date in Salesforce. Additionally, I have explained the syntax as well as examples related to the addmonth function.

You may like to read: