+ Start a Discussion
Glenn Nyhan 91Glenn Nyhan 91 

How to Calculate Number of Days Between Two Dates

I am trying to calculate the number of days between two date fields but my formula is not working and I can't figure out why. I have a field called Completion_Photos_Upload_Date__c and another called Completion_report_due__c. and a formula field called Completion_Photo_Timing which should calculate the number of days between the dates. Example: one record has a Completion Photos Upload Date of 5/28/2019 and a Finished School Photos Due date of 5/12/2019 which is 16 days. Right now with this formula: DATEVALUE(Completion_Photos_Upload_Date__c )- Completion_report_due__c only shows 9 days. Not sure what's wrong with this formula. There are no syntax errors but 9 days is not the correct answer. Any help fixing would be appreciated. 
Best Answer chosen by Glenn Nyhan 91
siddartha reddy kalamsiddartha reddy kalam
Hey Glenn,
Make sure you follow these steps:
1. select 'formula field'.
2. then select 'number'.
3.by using insert fields add (Completion_Photos_Upload_Date__c  - Completion_report_due__c).
this should work properly because i just i tried it with sample example.

All Answers

siddartha reddy kalamsiddartha reddy kalam
Hello Glenn,
Try writing it using Insert fields add (Completion_Photos_Upload_Date__c  - Completion_report_due__c)
Glenn Nyhan 91Glenn Nyhan 91
Hi Siddartha, I tried DATEVALUE(Completion_Photos_Upload_Date__c - Completion_report_due__c) and got the following error message: Error: Incorrect parameter type for operator '-'. Expected Number, DateTime, received Date I also tried using just (Completion_Photos_Upload_Date__c - Completion_report_due__c) and got this error message: Error: Incorrect parameter type for operator '-'. Expected Number, DateTime, received Date
siddartha reddy kalamsiddartha reddy kalam
Hey Glenn,
Make sure you follow these steps:
1. select 'formula field'.
2. then select 'number'.
3.by using insert fields add (Completion_Photos_Upload_Date__c  - Completion_report_due__c).
this should work properly because i just i tried it with sample example.
This was selected as the best answer
Glenn Nyhan 91Glenn Nyhan 91
I followed your directions and used (Completion_Photos_Upload_Date__c - Completion_report_due__c) but got this error message: Error: Incorrect parameter type for operator '-'. Expected Number, DateTime, received Date [image: screen.JPG]
Glenn Nyhan 91Glenn Nyhan 91
I see the issue here. I just created generic date fields and a formula field to subtract one date from another and it works. The issue I believe is that one field i.e. Completion Photos Upload Date field is a Date/Time field and Finished School Photos Due field is a Date field. I create two more fields Completion Photographs Upload Date field is a Date/Time field and Finished School Photographs Due both of which are just date fields and a new formula to subtract one from the other and it worked. Thanks for the help.