1

how to Calculate individual age based on Date of Birth using formula fields when i enter date of birth age must be updated

1
  • you have to take two fields by using roll-up summary you can calculate.
    – Sathya
    Commented Jan 28, 2014 at 7:01

3 Answers 3

2

Yo can use any of the following

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))

FLOOR((TODAY() - DateofBirth__c)/365.2425)


TEXT(YEAR(TODAY() ) - YEAR( YOUR_DATE_OF_BIRTH_API ))
1
  • 1
    How about to add some explanation to your answer? Commented Jan 28, 2014 at 7:18
1

@Satya.

Create field:Age(Formulae data type).

In the formulae use: year(Today())-year(DOB__C)

0

I had to create a formula for this recently, and it was a pretty painful endeavour. PS : I'm a newbie to Salesforce

The formula :

IF( 
  NOT(ISBLANK(Birthdate)),
  TEXT(
    IF( 
      MONTH(Birthdate) < MONTH(TODAY()), 
      YEAR( TODAY()) - YEAR( Birthdate ),
      IF( 
        MONTH(TODAY()) = MONTH(Birthdate) && DAY(TODAY()) >= DAY(Birthdate),
        YEAR( TODAY()) - YEAR( Birthdate ),
        YEAR( TODAY()) - YEAR( Birthdate) - 1) 
      )
    ) & 
    " Years, " &
    TEXT(
      IF( 
        MONTH(Birthdate) <= MONTH(TODAY()), 
        IF( 
          DAY(Birthdate)<=DAY(TODAY()),
          MONTH(TODAY())-MONTH(Birthdate), 
          IF(
            MONTH(TODAY())= MONTH(Birthdate),
            11,
            MONTH(TODAY())-MONTH(Birthdate) - 1
          ) 
        ),
        IF(
          DAY(Birthdate)<=DAY(TODAY()),
          12-MONTH(Birthdate)+MONTH(TODAY()),
          12-MONTH(Birthdate)+MONTH(TODAY())-1
        ) 
      )
    ) & 
    " Months, " & 
    IF(
      MONTH(TODAY())=4,
      TEXT( 
        IF(
          DAY(Birthdate) <= DAY(TODAY()), 
          TODAY()-DATE(
                    YEAR(TODAY()),
                    MONTH(TODAY()),
                    DAY(Birthdate)
                  ), 
          TODAY()- ADDMONTHS(
                     DATE( 
                       YEAR(ADDMONTHS(TODAY(),-1)), 
                       MONTH(ADDMONTHS(TODAY(),-1)), 
                       DAY(Birthdate)
                     ),0
                   ) 
        ) 
      ),
      TEXT( 
        IF(
          DAY(Birthdate) <= DAY(TODAY()), 
          TODAY()-DATE(
                    YEAR(TODAY()),
                    MONTH(TODAY()),
                    DAY(Birthdate)
                  ), 
          TODAY()- ADDMONTHS(
                     DATE( 
                       YEAR(
                         ADDMONTHS(TODAY(),-2)
                       ), 
                       MONTH(
                         ADDMONTHS(TODAY(),-2)
                       ), 
                       DAY(Birthdate)
                     ),1
                   ) 
        ) 
      )
    ) & 
    ' Days', 
  ""
)

For this to work you need to replace the Birthdate with your date field's name. This prints "X Years, X Months, X Days"

View on details page

PS : The TODAY() Field on the layout isn't being used in the formula, But you can modify all TODAY() in the formula to calculate the difference between any two dates by making Birthdate as the smaller date and replacing TODAY() with the greater date

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .