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
SF MasterSF Master 

Age Calculation

i am trying to caluclate AGE from Birthdate.

 

we have birthdate field  now. ( contact standard filed) .what is the best way to calculate age. can i write some formulae or trigger.

 

please advice 

 

Thanks.

Best Answer chosen by Admin (Salesforce Developers) 
Cory CowgillCory Cowgill

You can do this in a Formula Field.

 

Formula is:

IF(MONTH(TODAY())>MONTH(Birthdate),YEAR(TODAY())-YEAR(Birthdate),IF(AND(MONTH(TODAY())=MONTH(Birthdate),DAY(TODAY())>=DAY(Birthdate)),YEAR(TODAY())-YEAR(Birthdate),(YEAR(TODAY())-YEAR(Birthdate))-1))

All Answers

Cory CowgillCory Cowgill

You can do this in a Formula Field.

 

Formula is:

IF(MONTH(TODAY())>MONTH(Birthdate),YEAR(TODAY())-YEAR(Birthdate),IF(AND(MONTH(TODAY())=MONTH(Birthdate),DAY(TODAY())>=DAY(Birthdate)),YEAR(TODAY())-YEAR(Birthdate),(YEAR(TODAY())-YEAR(Birthdate))-1))

This was selected as the best answer
SF MasterSF Master

Thank you cory ....

SF MasterSF Master

this is simply Great its working awesome..

Ritik DwivediRitik Dwivedi
thank you Cory Cowgill
Bessem TOUHAMI 12Bessem TOUHAMI 12
A better and easier formula to calculate age 
(TODAY() - Birthdate) / 365.25
This formula calculates the years between the current date (TODAY()) and the person's birthdate, considering leap years.