function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Neelam BasakNeelam Basak 

Calculate End Date

Hi Experts,

Below are the fields
     Field Name                         Datatype
1. Agreement Start Date -          Date 
2. Term(in months) -                   Number 
3. Agreement End Date -            Date 

ISSUE:
a)  Whenever I entered Agreement Start date and Term(in months) it should automatically calculate Agreement End Date. 

I tried to calculate Agreement End Date with the below formula, it is giving me the incorrect End Date.
Agreement_Start_Date__c + (365* VALUE( TEXT( Term_Months__c ) ))

Please Help!

Thanks,
Neelam
Best Answer chosen by Neelam Basak
Khan AnasKhan Anas (Salesforce Developers) 
Hi Neelam,

Greetings to you!

Please use below formula:

Create a formula field, with the return type 'Date'
DATE (
YEAR ( StartDate__c ) + FLOOR ( (MONTH ( StartDate__c ) -1 + Number_of_Months__c)/12),
CASE ( MOD ( MONTH ( StartDate__c )+Number_of_Months__c, 12 ),0,12,MOD ( MONTH ( StartDate__c )+Number_of_Months__c, 12 )),
MIN ( DAY ( StartDate__c ),
CASE ( MOD ( MONTH ( StartDate__c )+Number_of_Months__c,12 ) ,9,30,4,30,6,30,11,30,2,28,31 ) )
)

Please refer to the below link which might help you further with the above issue.

https://help.salesforce.com/articleView?id=000004519&language=en_US&type=1

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Thanks and Regards,
Khan Anas