I need to include a date field in my workflow rule criteria.

The field "registerDate__c" is of type DATETIME.

My criteria should express that the registerDate__c is longer than 30 days ago.

I wrote:

Now() - registerDate__c > 30

Obviously this is incorrect, because the result of this equation is probably not in days?.

My whole workflow criteria is:

A_Stage__c == 'Applicant' && 
NOT(ISPICKVAL(Status__c, 'Lost')) && 
Now() - Qual__r.registerDate__c > 30

When this criteria evaluates to true, I will update a field. Usually, when working with date fields in a workflow, I would use a time-based workflow, but in this case, my date field is in a related object, so I am not sure which way would be the best to do it.



Use the DATEVALUE() function to first cast NOW to a Date type rather than a Datetime type. Then you your subtraction logic should work. As an example:

A_Stage__c == 'Applicant' && 
NOT(ISPICKVAL(Status__c, 'Lost')) && 
DATEVALUE(Now()) - Qual__r.registerDate__c > 30

More on the DATEVALUE function here: https://help.salesforce.com/htviewhelpdoc?id=customize_functions_a_h.htm&siteLang=en_US#DATEVALUE

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.