To find the age of items such as the age of person, age of an account, age of the client relationship, etc., a custom formula field can be created to calculate the time difference between two dates.

The formula field should be placed on the object it is doing the calculation from. For example if you want the how long an account has been active, the formula field would be placed on the Account object. To calculate the age of a Contact based on their birth date, the formula field would be placed on the Contact object.

To create a formula field to calculate age based on a Contact birth date:

- Go to
**Setup**->**Customize**->**Contact**->**Fields**- In Lighting go to
**Setup**->**Object Manager**->**Contact**->**Fields & Relationships**

- In Lighting go to
- Click
**New**to create a custom field. - Select
**Formula**from the Data Type List and click**Next**.

- Enter a field label (e.g., Current Age).
- Choose
**Number**for the Return Type with**0**decimal places.

- Paste the following formula into the Formula box:

IF( NOT( ISBLANK( Birthdate ) ) , IF( DATE( 2000 , MONTH( Birthdate ) , DAY( Birthdate ) ) <= DATE( 2000 , MONTH( TODAY() ) , DAY( TODAY() ) ), YEAR (Today()) - YEAR ( Birthdate ), YEAR (Today()) - YEAR ( Birthdate ) -1 ), null)

__Translation__: If the Birthdate field is not blank then check to see if the Birthdate month and day are less than or equal to today. If the Birthdate is less than or equal to today, then subtract the year of Today’s date from the year of the Birthdate. If the Birthdate is greater than today, then subtract Today’s year from the year of the Birthdate minus 1.

If you are using a different date field, replace “Birthdate” with the desired object’s name.

- Click the
**Check Syntax**button at the bottom of the Formula box. If no syntax errors, click**Next**. - Choose what user Profiles with be able to see the new field and to edit the field. Keep
**Read Only**checked as the formula is driving the data. - Click Next
- Choose what Page Layouts the new field will be displayed on. You can go into Page Layouts later to reposition the field on the page.
- Click
**Save**. Go to the Contact page and verify the Current Age field is populating correctly.

Enjoy!

Thanks Becci. Handy formula.

Hello, Ken Tallman, your formula solution is excellent, Thank you very much

Awesome , is there a way to add the number of days as well to the formula?

Rynard,

By default the result of subtracting the newer date from the older will be in days (e.g., Date_1 – Date_2).

Here are more date formula examples: https://help.salesforce.com/articleView?id=formula_examples_dates.htm&type=5

What does the figure 2000 in above formula indicates?

Monika, the 2000 has to do with whether you were born after or before the year 2000 (and the math). If you’re after 2000, it’s a simple subtraction of today’s year minus 2000. If before, we have to do also add in the years of 2000-birthyear. If I’m 1974 which I am, it’s 2000-1974 plus 2021-2000 to get my huge number. 🙂

Hope that helps!

Why use so huge formula to calculate age when we can use this

YEAR (Today()) – YEAR ( Birthdate )

I understand what you’re saying, but this takes into account whether the birtdate is before or after today (hence the -1). This gives more of an exact age instead of just year subtraction.

Thanks for this. The version that’s floating around elsewhere is

FLOOR( (TODAY()-Birthdate +1) /365.2425)

I haven’t gotten a wrong answer from it yet, but I suspect that there’s a very narrow window of time on the person’s exact birthday where that could happen. If it does, I’ll keep this one around as a backup.

Hi. I understand this calculated in years. What if I want to know the age in months?

I think what you could do (keeping in mind that this should be doing a count of days), can you throw in a “/30” at the end? that would divide days by months. It won’t be exact but close?