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
Kelly Campbell 4Kelly Campbell 4 

subtract contract start date from contract end date

Hey all, This is probably silly but I can't figure it out.

I'm trying to create a formula field (Contract Term in months) to get number (of months) a contract is, by subtracting my Subscription End Date custom date field from my Subscription Start Date custom field.

This isn't working:  DATEVALUE(Pilot_Start_Date__c) - DATEVALUE(Pilot_End_Date__c)
Error: Incorrect argument type for function 'DATEVALUE()'.

Can anybody help?  Thanks a million!

Kelly
Best Answer chosen by Kelly Campbell 4
Ross Gilbert 18Ross Gilbert 18
Not sure if something like this would work roughly (formula field with output type = Number) 

(Pilot_End_Date__c-Pilot_Start_Date__c)/31

All Answers

Pankaj_GanwaniPankaj_Ganwani
Hi,

Please refer below link for your answer;
https://success.salesforce.com/answers?id=90630000000h22TAAQ
Ross Gilbert 18Ross Gilbert 18
Not sure if something like this would work roughly (formula field with output type = Number) 

(Pilot_End_Date__c-Pilot_Start_Date__c)/31
This was selected as the best answer
Kelly Campbell 4Kelly Campbell 4
Thanks for your help guys!  @Pankaj_Ganwani I tried that formula with a TEXT output but for my contract from 1/1/14 to 2/28/14 it only counted it as 1 month.... 

@Ross that works, thanks!
Kelly Campbell 4Kelly Campbell 4
@Ross_Gilbert okay now I'm trying to add two formula fields together (Pilot contract term + subscription contract term) to give me a TOTAL Contract Term... but I'm not getting anything back when I do the following (just blanks!)

(Pilot_Term_months__c + Subscription_Term_months__c)

Any Suggestions?
Ross Gilbert 18Ross Gilbert 18
What are the field types for those 2 formula fields?  Are they both Number type formula fields?
Kelly Campbell 4Kelly Campbell 4
they are both formula fields but their output are numbers!