I'm trying to write validation rule which states that,
schedule_date__c
should be within 30 days from start_date__c
and end_date__c
I have done the following but not sure why the validation is not working.
Validation rule:
AND(schedule_date__c,
((start_date__c - end_date__c) < 30))
Best Answer
The
AND
logical function is described as this:So in your Validation Rule, you checking for this:
schedule_date__c
field?AND
start_date_c
andend_date__c
values less than 30 [days]?There are a couple of issues:
You are not directly comparing
schedule_date__c
to anything to do with Start or End Dates.Subtracting End Date from Start Date (assuming that End Date is always later than Start Date) will always be less than 30, because the answer will always be negative.
If by
you mean that Schedule Date should be inside of 30 days after the Start Date or inside of 30 days before the End Date, then the following Validation Rule formula should work*:
* assuming that all the fields are the same Date type
UPDATE
After chat discussion, requirements were clarified and some "givens" determined.
GIVENS
REQUIREMENTS
VALIDATION RULE
What this does:
...then the formula returns
TRUE
and the error is displayed: