Recently I got inspired from one of my favorite technical article spot (http://forceguru.blogspot.com/2011/05/calculating-age-from-birth-date.html) for calculating Age of from Date of Birth. Here I have added some flexibility for getting age up to month Level just copy and paste following code in your formula field (which should be of number type).of years
**********************************************************************************
If(
OR(
And(
MONTH(TODAY())>=MONTH(DOB_API),DAY(TODAY())>=DAY(DOB_API)
),
And(
MONTH(TODAY())>MONTH(DOB_API),DAY(TODAY())<DAY(DOB_API )
)
),
(YEAR(TODAY())-YEAR(DOB_API)),
If(
OR(
And(
MONTH(TODAY())<=MONTH(DOB_API),DAY(TODAY())>=DAY(DOB_API)
),
And(
MONTH(TODAY())<=MONTH(DOB_API),DAY(TODAY())<DAY(DOB_API)
)
),
(YEAR(TODAY())-YEAR(DOB_API )-1),
0
)
)
**********************************************************************************
and for months copy and paste following code in your formula field (which should be of number type).of months.
**********************************************************************************
**********************************************************************************
**********************************************************************************
If(
OR(
And(
MONTH(TODAY())>=MONTH(DOB_API),DAY(TODAY())>=DAY(DOB_API)
),
And(
MONTH(TODAY())>MONTH(DOB_API),DAY(TODAY())<DAY(DOB_API )
)
),
(YEAR(TODAY())-YEAR(DOB_API)),
If(
OR(
And(
MONTH(TODAY())<=MONTH(DOB_API),DAY(TODAY())>=DAY(DOB_API)
),
And(
MONTH(TODAY())<=MONTH(DOB_API),DAY(TODAY())<DAY(DOB_API)
)
),
(YEAR(TODAY())-YEAR(DOB_API )-1),
0
)
)
**********************************************************************************
and for months copy and paste following code in your formula field (which should be of number type).of months.
**********************************************************************************
If(
OR(
And(
MONTH(TODAY())>=MONTH(DOB_API),DAY(TODAY())>=DAY(DOB_API)
),
And(
MONTH(TODAY())>MONTH(DOB_API),DAY(TODAY())<DAY(DOB_API )
)
),
MONTH(TODAY())-MONTH(DOB_API) ,
If(
OR(
And(
MONTH(TODAY())<=MONTH(DOB_API),DAY(TODAY())>=DAY(DOB_API)
),
And(
MONTH(TODAY())<=MONTH(DOB_API),DAY(TODAY())<DAY(DOB_API)
)
),
(12-MONTH(DOB_API ))+MONTH(TODAY()) ,
0
)
)
**********************************************************************************
I would like to refer great thanks and whole credit to Mr. Ankit Arora dropping focus on this topic.
Source : http://forceguru.blogspot.com/2011/05/calculating-age-from-birth-date.html
No comments:
Post a Comment