September 29, 2020

How to find the number of months between two Dates using formula in Salesforce?

Sample Formula:
 
IF(
YEAR( End_Date__c ) = YEAR( Start_Date__c ) && MONTH( End_Date__c ) = MONTH( Start_Date__c ),
0,
IF ( YEAR( End_Date__c ) = YEAR( Start_Date__c ),
MONTH( End_Date__c ) - MONTH( Start_Date__c ) - 1,
( ( YEAR( End_Date__c ) - YEAR( TODAY() ) ) * 12 ) - ( 13 - MONTH( End_Date__c ) ) + ( 12 - MONTH( Start_Date__c ) )
)
)
 
Output:
 


No comments:

Post a Comment