0

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

4
  • Can you share what you have tried?
    – glls
    Commented Oct 19, 2017 at 16:56
  • Sure I tried (MONTH(EndDate)-MONTH(StartDate))/30 but I realize now that definitely wont work
    – user5428
    Commented Oct 19, 2017 at 17:00
  • Sorry, updated my comment
    – user5428
    Commented Oct 19, 2017 at 17:02
  • Did you try it? success.salesforce.com/answers?id=90630000000h22TAAQ
    – m Peixoto
    Commented Oct 19, 2017 at 17:44

1 Answer 1

1

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

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .