0

I am trying to create a formula field to set a DateTime value, but it fails with the following error:

Error: Incorrect parameter type for function 'IF()'. Expected Number, received DateTime

The formula I am trying to construct is as follows:

IF(MQL_Date__c < First_Sales_Activity_Logged__c, First_Sales_Activity_Logged__c-MQL_Date__c, MQL_Date__c)


MQL_Date__c - Date/Time
First_Sales_Activity_Logged__c - Date/Time
Formula Field - Date/Time

Only if MQL_Date__c is less than First_Sales_Activity_Logged__c than set the formula value to First_Sales_Activity_Logged__c-MQL_Date__c else MQL_Date__c

  • 1
    what is the return type of your formula field? Is it a date? Or a Number? – m Peixoto Apr 22 at 10:23
  • your formula does not make so much sense. One parameter of the IF function, you are returning a date, in the other, you are returning the operation minus between two dates.... – m Peixoto Apr 22 at 10:24
  • When you say, your formula value should be First_Sales_Activity_Logged__c-MQL_Date__c, what do you mean by that ? Do you need the difference between dates ? – Vijay Ganji Apr 22 at 10:25
  • Formula DataType is Date/Time. The Data type of all the fields used in the expression is Date/Time. MQL_Date__c - Date/Time First_Sales_Activity_Logged__c - Date/Time – nevrekar_amey Apr 22 at 10:26
  • @VijayGanji yes the difference between the two Date/Time fields, First_Sales_Activity_Logged__c and MQL_Date__c – nevrekar_amey Apr 22 at 10:28
2

You cannot return a DateTime by subtracting two DateTime fields, it will always return you the difference in number of days.

Also, your formula should return the value of same type in all the conditions, i.e. in your case, it is returning Integer in one case and DateTime in another case which is incorrect.

If you want to display the difference between two DateTime fields, you will have to change your formula return type to either Number or Text and show the difference.

  • That makes sense. Thanks for the help here. – nevrekar_amey Apr 22 at 10:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.