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
hylim12hylim12 

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.

Best Answer chosen by hylim12
GlynAGlynA

@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

All Answers

Arunkumar.RArunkumar.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..!

hylim12hylim12

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

Arunkumar.RArunkumar.R

Yes it will work...

hylim12hylim12

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 KimarPraveen Kimar

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

hylim12hylim12

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

GlynAGlynA

@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