1
IF(
    ISBLANK(Implemented_Date__c), 
    TODAY() - DATEVALUE(CreatedDate), 
    Implemented_Date__c - DATEVALUE(CreatedDate)
)

I keep getting this error message:

Error: Incorrect parameter type for operator '-'. Expected Number, DateTime, received Date

what could be the challenge and this is a trailhead challenge.

1 Answer 1

1

Date and DateTime are closely related, but they are separate data types.

Generally speaking, when you have an operator (like addition, subtraction, less than, etc...), both of the operands need to be of the same type. Apex (Salesforce's proprietary, java-like programming language) can be a bit more flexible, but you're working with a formula ...which is not Apex.

TODAY() returns a Date.
CreatedDate (contrary to its name) is a DateTime. You appear to be handling this correctly by turning it into just a Date (via the DATEVALUE() function). In other words, you need to make sure that the data "type" matches.

So, given your error, the only possibility I see is that Implemented_Date__c is a DateTime instead of a Date. If you turn it into a Date using DATEVALUE() (like you did with CreatedDate), then the formula ought to save without complaints.

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.