1

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

8
  • 1
    what is the return type of your formula field? Is it a date? Or a Number?
    – m Peixoto
    Apr 22, 2019 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, 2019 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 ? Apr 22, 2019 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 Apr 22, 2019 at 10:26
  • @VijayGanji yes the difference between the two Date/Time fields, First_Sales_Activity_Logged__c and MQL_Date__c Apr 22, 2019 at 10:28

1 Answer 1

3

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.

1
  • That makes sense. Thanks for the help here. Apr 22, 2019 at 10:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .