ShowAll Questionssorted byDate Posted
hylim12

# calculate age based on DOB dynamically Every Year

Hi,

i have a formula field to calculate my contact's age based on DOB. I would like know, will Salesforce auto update the age field yearly to change the age?

Meaning that, the moment i create a contact with DOB = 1 Dec 1980 and my formula field will calculate the age as 33 (2013 - 1980). When reach 2014, is there a way to auto update the age to 34 (2014-1980) and subsequenctly to 35,36,37.. without editing the contact?

Thanks.

GlynA

@hylim12,

The formula (any formula) will be evaluated every time the record is queried.  The formula result is not actually stored in the record.  This means that the formula will be correct now and always.  There is no need to "update" the field.

If this helps, please mark it as a solution, and give kudos (click on the star) if you think I deserve them. Thanks!

-Glyn Anderson
Certified Salesforce Developer | Certified Salesforce Administrator

Arunkumar.R

Create a formula field with return type Number with decimal point 0 and put this below formula,

YEAR(TODAY()) - YEAR(DateOfBirth__c)

Where DateOfBirth__c is your Date field...

Hope this may helpful to you..!

hylim12

does it mean that this formula will auto evaluate every year automatically?

Arunkumar.R

Yes it will work...

hylim12

if i have formula like this :

```IF(

MONTH(TODAY())>MONTH(DOB__c),

YEAR(TODAY())-YEAR(DOB__c),

IF(AND(MONTH(TODAY()) = MONTH(DOB__c), DAY(TODAY()) >= DAY(DOB__c)),

YEAR(TODAY())-YEAR(DOB__c),

(YEAR(TODAY())-YEAR(DOB__c))-1)

)```

will it auto evaluate it every year? how frequent salesforce will evaluate this formula? i have like 122512 contact all with different birthdate, will salesforce check every second and change the age accordingly?

Praveen Kimar

TEXT(YEAR(TODAY() ) - YEAR( YOUR_DATE_OF_BIRTH_API ))

hylim12

Only YEAR will have auto calculation? how about until MONTH?

GlynA

@hylim12,

The formula (any formula) will be evaluated every time the record is queried.  The formula result is not actually stored in the record.  This means that the formula will be correct now and always.  There is no need to "update" the field.

If this helps, please mark it as a solution, and give kudos (click on the star) if you think I deserve them. Thanks!

-Glyn Anderson
Certified Salesforce Developer | Certified Salesforce Administrator

This was selected as the best answer