I have validation rule which will throw if the selected date is not last day of previous month after one year

Example - today is Oct 1,2021 then my validation should fire if selected date is not Sept 30,2022 Below is my validation rule but it is not firing. What i am missing?

Edate__c != DATE(YEAR(today()) +1, MONTH(today()) + 1, 1) - 1


Looks to me like your month math is incorrect

Partially evaluating DATE(YEAR(today()) +1, MONTH(today()) + 1, 1) - 1, you'd get
DATE(2022, 11, 1) (i.e. 1st of November, 2022)

MONTH(today()) + 1 should be MONTH(today()) - 1

Beyond that, you haven't provided a lot of information to work from.

If this is the entire validation rule, then you'd run into issues trying to make changes to any existing records. You'd need to update Edate__c for every record you want to change on every day you want to make a change (which my gut says is likely not what you want to have happen).

  • This is the only validation rule i have. I did change MONTH(today()) - 1 but still no luck. Oct 1 at 20:17
  • @sfdcdeveloper To emphasis the last point, use AND( ISCHANGED(Edate__c), ... to make sure the validation rule only checks when required Oct 2 at 8:52
  • I have added ISCHANGED but still my validation rule is not firing correctly Oct 3 at 0:45

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.