function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jackie HeathJackie Heath 

Validation to specify a date entere is between two dates

If a date field is populated the date should be more than 28 days from the current date (today) and less than 120 days for the current date (today).  If the date field is blank the rule should not fire.
JakesterJakester
Ok, couple of questions:

  1. You can't have a date that is both 28 more from today and 120 less than today - did you mean that it could be anywhere in the range of 28 more or 120 less?
  2. Assuming, the answer is yes, when you say "more than 28 days from the current date," how do you want it to work 28 days later? In other words, if it's 10/1/08 and the user enters 10/30/08 then it would error, right? But what happens when it's 10/3/08? Then are they allowed to on the existing record? What about new records?
  3. Assuming that's always looking at today's date, then that means that every record will eventually fail this rule. This means that anytime anyone goes to edit any other field on the record, it won't let them once the date that's been entered is far enough in the past
With all that said, and assuming that I'm on the right track with #1 and #2 and you're ok with #3, then it would be a pretty simple validation rule - something like

Code:
and(
     not isnull(my_date__c)
    ,and(
          my_date__c + today() > 28
         ,my_date__c - today() > 120
     )
)