1

I want to ensure that the age of my contacts be less than 20 years, 5 months and 15 days.

Till 20 years and 5 months, I am able to write the rule by multiplying the years with 12 and adding the months to it and then comparing. But I am unable to figure out how to check for 15 days in the validation rule.

How can this be achieved keeping the leap years in consideration ?

1
  • Please edit your post to include your validation rule. Commented Aug 25, 2020 at 18:12

1 Answer 1

1

In a validation rule I think you will be unable to account for leap years. In this case I would just convert your 20 years, 5 months and 15 days to days.

Birthdate > (TODAY() - 7467)

If you are building this out in Apex you might be able to use isLeapYear() to help you but it would be quite messy.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_date.htm

1
  • 1
    Based on your answer, I wrote Birthday < ADDMONTHS((TODAY()-29),-251) and it appears to be working fine despite the leap years in between
    – N_H1922
    Commented Aug 26, 2020 at 7:32

You must log in to answer this question.

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