I'm trying to write validation rule that end_date__c
should be <=
start_date__c
isHired__c is boolean
But does not seems to work, for an example:
my start_date__c = 8/8/2016 11:34 AM
end_date__c = 8/8/2016 11:34 AM
the validation should accept since I'm checking to see if the start <= but I'm keep getting the validation message as if the condition did not match.
here is what I have got:
AND
(
(DATEVALUE(start_date__c) - end_date__c) <=1, isHired__c, ISPICKVAL(status__c, 'Approved')
)
Best Answer
Start Date minus End Date means that the result would be negative if the End Date was after the Start Date, which should trigger this rule. Instead, you meant to say End Date minus Start Date, which would be negative if the Start Date was after the End Date. Of course, as Adrian said, simply use the comparison operators directly, which helps you avoid that common mistake:
As, as you've noticed, when doing your math, if Start Date and End Date are the same, you'd also get the error (0 is less than 1).