Adding some number of months (term) to a start date to calculate end date may seem straightforward enough, but there are different interpretations and business needs for how many days a "month" should be since actual calendar months are 28, 29, 30, or 31 days long.
There are additional considerations and possible pitfalls such as:
VARIATION 1: Use day of month from Start Date and restrict to last day of short months
Simply use the ADDMONTHS() function for these requirements.
Create formula field (date): "End Date"
Description: "Add number of calendar months, but restrict to last day of short months as needed"
Help text: "Start Date + Months restricted to last day of short months as needed"
Formula:
IF( ISBLANK( Start_Date__c )
|| ISBLANK( Months__c ) ,
NULL ,
ADDMONTHS( Start_Date__c , Months__c )
)
VARIATION 2: Month = 28 days (or 30 or 31, or any other fixed number)
NOTE: To use a number other than 28, substitute in that preferred number in place of 28 in this formula.
Create formula field (date): "End Date"
Help text: "Months are 28-day periods"
Formula:
IF( ISBLANK( Start_Date__c )
|| ISBLANK( Months__c ) ,
NULL ,
/* Add given number of 28-day months to Start Date */
Start_Date__c + ( Months__c * 28 )
)
VARIATION 3: Use a given day of the month (e.g. the 1st, or the 15th, etc.) for all End Dates
NOTE: For End Date to always have a given day of the month, never choose a number greater than 28 since this would lead to invalid dates for the shorter months.
Create formula field (date): "End Date"
Description: "Mathematically determine end year & month, but use fixed company standard day of month for all End Dates."
Help text: "End Date is always on the 15th of its month"
Formula:
IF( ISBLANK( Start_Date__c )
|| ISBLANK( Months__c ) ,
NULL ,
/* Calculate End Date */
DATE(
/* Calculate the year of the End Date */
YEAR( ADDMONTHS( Start_Date__c , Months__c )) ,
/* Calculate the month number of the End Date */
MONTH( ADDMONTHS( Start_Date__c , Months__c )) ,
/* Set end day */
15 ) /* Fixed company standard End Date day of month */ Substitute in preferred day
)
VARIATION 4: Use day of month from Start Date; push invalid dates in short months to 1st day of the next month (e.g. change April 31 to be May 1 instead)
Create underlying hidden formula fields to make ultimate formula field easier to read, create, modify, and understand. NOTE: This variation includes the creation of 3 formula fields.
1) Create hidden formula field (number, 0): "End Year"
Description: "This hidden field will be referenced in End Date formula field."
Formula:
IF( ISBLANK( Start_Date__c )
|| ISBLANK( Months__c ) ,
NULL ,
/* Calculate the year of the End Date */
YEAR( ADDMONTHS( Start_Date__c , Months__c ))
)
2) Create hidden formula field (number, 0): "End Month"
Description: "This hidden field will be referenced in End Date formula field."
Formula:
IF( ISBLANK( Start_Date__c )
|| ISBLANK( Months__c ) ,
NULL ,
/* Calculate the month number of the End Date */
MONTH( ADDMONTHS( Start_Date__c , Months__c ))
)
3) Create formula field (date): "End Date"
Description/Help text: "Start Date + Months on same day of the month unless beyond the end of a short month, then the 1st of the next month"
Formula:
IF( ISBLANK( Start_Date__c )
|| ISBLANK( Months__c ) ,
NULL ,
/* Check for invalid End Date beyond the end of short months */
IF(
/* February invalid End Date for leap and non-leap years */
( End_Month__c = 2
&&
(
( MOD( End_Year__c , 4 ) <> 0 /* Not a leap year */
&& DAY( Start_Date__c ) > 28 ) /* Beyond Feb 28 */
||
( DAY( Start_Date__c ) > 29 ) /* Leap year beyond Feb 29 */
))
||
/* 30-day month and End Date would fall on the 31st */
(( End_Month__c = 4 /* April */
|| End_Month__c = 6 /* June */
|| End_Month__c = 9 /* September */
|| End_Month__c = 11 ) /* November */
&& DAY( Start_Date__c ) = 31 ) ,
/* Use 1st day of next month to avoid invalid End Date at end of shorter months */
DATE ( End_Year__c , End_Month__c + 1 , 1 ) ,
/* Or use same day of month as Start Date if End Date is a valid date */
DATE( End_Year__c , End_Month__c , DAY( Start_Date__c ))
))
000381089

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.