You need to sign in to do that
Don't have an account?
Matheus Antonio da Silva
Validation Rule - Age higher than 17 years old
Hello guys!
I've been struggling with a validation rule. There is a field called "Birthday" where the user populates his/her birthday. When the user populates this field, then it has to allow only ages higher than 17 years old.
For example:
User's birthday: 02/02/2005
Today's date: 15/05/2019
So it means that the user's age is bellow 18, hence it is not accepted.
How can I do it? I've made it doing the following code, but it didn't work as I wanted:
I did other things, but there were incorret datas that were allowed instead of being denied. Could you guys please help me?
I've been struggling with a validation rule. There is a field called "Birthday" where the user populates his/her birthday. When the user populates this field, then it has to allow only ages higher than 17 years old.
For example:
User's birthday: 02/02/2005
Today's date: 15/05/2019
So it means that the user's age is bellow 18, hence it is not accepted.
How can I do it? I've made it doing the following code, but it didn't work as I wanted:
(TODAY() - DadosPF_DataNascimento__c < 18*365)
I did other things, but there were incorret datas that were allowed instead of being denied. Could you guys please help me?
https://developer.salesforce.com/forums/?id=906F00000008wdEIAQ
https://www.marksgroup.net/blog/salesforce-com-adding-a-formula-field-to-calculate-age-from-another-date-field/
Please try this formula below:
YEAR(TODAY()) - YEAR(Birthday__c) <= 17
Hope this will help you.
Thanks,
Jega
Thanks for supporting me guys!
I had to do it for 18: TODAY() >= ADDMONTHS(Birthdate__c,216)
for 17 it should be: TODAY() >= ADDMONTHS(Birthdate__c,204)
today()- Date_of_Birth__c < 17*365
To create a validation rule that allows only ages higher than 17 years old based on the "Birthday" field, you can use the following formula:
Here's an explanation of the formula:
Today() represents the current date.
DATEVALUE(Birthday__c) converts the "Birthday" field into a date value.
Today() - DATEVALUE(Birthday__c) calculates the difference between the current date and the "Birthday" date in days.
18*365 represents 18 years converted into days. Note that this is an approximation and does not account for leap years.
The comparison Today() - DATEVALUE(Birthday__c) < 18*365 checks if the calculated difference is less than 18 years.
By using this formula in your validation rule, it will only allow ages higher than 17 years old, denying any entry where the age is equal to or less than 17 years.
Make sure to replace Birthday__c with the actual API name of the "Birthday" field in your Salesforce org. https://mcdvoice.me/