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? Commented Oct 19, 2017 at 16:56
  • Sure I tried (MONTH(EndDate)-MONTH(StartDate))/30 but I realize now that definitely wont work Commented Oct 19, 2017 at 17:00
  • Sorry, updated my comment Commented Oct 19, 2017 at 17:02
  • Did you try it? success.salesforce.com/answers?id=90630000000h22TAAQ 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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.