I have two custom date fields on the contract object called contract start date and contract end date that are both just date fields.

How would I write a custom formula field that looks at both and tells me the number of months for the contract?

Tried, (MONTH(EndDate)-MONTH(StartDate))/30 so far

and then (EndDate - StartDate)/30 which works sometimes but not others


I tested this formula and works fine

    ( (YEAR(End_Date__c ) - YEAR(Start_Date__c ) - 1) *12 ) 
    + (12 - MONTH(Start_Date__c ) +1)
    + MONTH(End_Date__c )
    - 1 
    + IF(DAY(End_Date__c ) > DAY(Start_Date__c ),1,0)

you can do a -1 if you will not consider the first month = 1

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.