0

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

1 Answer 1

2

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).

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .