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
monkeykingmonkeyking 

Incorrect parameter type for operator '-' Expected Number, Received Date error in Formula Field

Hello All,

I have a formula field in which i have to calculate the number of days between the two dates excluding weekends.
I got the formula from Salesforce docs to calculate the number of working days.

Now when i implement that in my org i am getting the below error,
User-added image
Can anyone please give the solution? How to get rid of this error?

Thanks in advance.

Regards,
Rajkumar CV
ApuroopApuroop
Hey RajKumar,

Looks like you have an extra bracket in between and leaving the '-' alone, that's the error. Try the below formula.
(5 * 
    (
        FLOOR( AV_Closed_Date__c - DATEVALUE(AV_subCase_Received_Date_c__c) - DATE(1900,1,8) ) / 7 
    )  + 
        MIN( 5, MOD(AV_Closed_Date__c - DATEVALUE(AV_subCase_Received_Date_c__c) - DATE(1900,1,8), 7) )
) - 
(5 * 
    (
        FLOOR( (DATEVALUE(ReOpen_Completed_date__c) - AV_Reopned_Date__c - DATE(1900,1,8) ) / 7 )
    ) +
        MIN( 5, MOD(DATEVALUE(ReOpen_Completed_date__c) - AV_Reopned_Date__c - DATE(1900,1,8), 7) )
)
Use programs like VSCode, Notepad++ for indentation which really helps.
 
monkeykingmonkeyking
I have tried and getting the same error.
ApuroopApuroop
Can you copy - paste the formula here? And all those fields are Date fields, correct?
Deepali KulshresthaDeepali Kulshrestha
Hi rjk.cv7,
Greetings to you!

rjk.cv7, the issue has to do with this field's data type:
- Please check if any field has data type is Date/Time
- You created Date as a Date/Time field when it should be a Date field. Just change the data type of this field to be a Date. It will work fine.
    
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha.