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
PlunkettPlunkett 

Count of Months and Days between two dates

Hi,
 
Is it possible to calculate the number of Months and Days between two dates?
 
Thanks
 
Ben
werewolfwerewolf
To count the days, just subtract one date field from the other. 

Months will be more difficult, but you can probably do it or approximate it by using the YEAR function to get each year, subtract one from the other and multiply by 12, and then use the MONTH function and subtract one from the other there too.
PlunkettPlunkett
Cool, thanks, I'll give that a go
nwingnwing
Here Is What I Have Used
 
Code:
((YEAR( End_Date__c ) - YEAR( Start_Date__c )) *12) + (MONTH( End_Date__c ) - MONTH( Start_Date__c ) )

 
nwingnwing
 
 
CORRECTION - add a 1 to the resulting number from the above equation as well...
nwingnwing

even better.... (allows for non start dates of the first of the month)

 

Code:
IF(DAY(Start_Date__c) = 1, (((YEAR( End_Date__c ) - YEAR( Start_Date__c )) *12) + (MONTH( End_Date__c ) - MONTH( Start_Date__c ) ) +1), ((YEAR( End_Date__c ) - YEAR( Start_Date__c )) *12) + (MONTH( End_Date__c ) - MONTH( Start_Date__c ) ) )


 

 

jd123jd123

Hi

 

    Yeah you are right but If Start Date is 12/31/2012 and End Date 1/1/2013 then it is giving 1 months Actual answer is only one day.

 

     would you please give with right formula.