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
Sagar MadkaikarSagar Madkaikar 

Find Difference Between 2 Dates in Months and Days

Hi,

I have a requirement where we need to find the difference between 2 different Date fields.
1. Start_Date__c.
2. End_Date__c.

We want to Store the Month difference in Field "Months__c" and Days difference in the field "Days__c" where both are Formula Fields..

For Example:

Start_Date__c = 01/04/2017
End_Date__c =  01/05/2017

Hence, the Month Difference should be 1 Month & Days Difference should be 1Day.

Please Let me know if any one of you have encountered this before or have any appropriate solution for this.

Thanks
Anurag SaxenaAnurag Saxena

Hi Sagar,

Please Use this formula's for your requirement

For Month__c
IF( Month(End_Date__c)  -  Month(Start_Date__c)  > 1, TEXT(FLOOR(Month(End_Date__c)  -  Month(Start_Date__c))) & " Month ", "1 Month")

For day__c 
IF( End_Date__c  -  Start_Date__c  > 0, TEXT(FLOOR(End_Date__c  -  Start_Date__c)) & " day ", "")

Ideally as per you example it should show 0 month and 1 day

If you want to use that condition, use below mentioned formula for month

For Month__c
IF( Month(End_Date__c)  -  Month(Start_Date__c)  > 0, TEXT(FLOOR(Month(End_Date__c)  -  Month(Start_Date__c))) & " Month ", "")

let me know if it helps

 

Thanks