Hi All,
Need help on writing a formula that will calculcate an
employees age as of the current date. Need years and months. Using CR9, Oracle database. The birthdate field is a string yyyymmdd.
Name: {@YEARS} Formula: IF (Date (2000,Month({@BD_Date}),Day({@BD_Date}))) > (Date (2000,Month(CurrentDate),Day(CurrentDate)))
THEN (Year(CurrentDate) - Year({@BD_Date}))-1
ELSE IF Date (2000,Month({@BD_Date}),Day({@BD_Date})) <= Date (2000,Month(CurrentDate),Day(CurrentDate))
THEN (Year(CurrentDate) - Year({@BD_Date}))
ELSE 100
//Calculates Whole Years Elapsed
Name: {@MONTHS} Formula: IF ((Date (2000,Month({@BD_Date}),Day({@BD_Date}))) >= (Date (2000,Month(CurrentDate),Day(CurrentDate)))
AND (Date (2000,Month({@BD_Date}),1)) <> (Date (2000,Month(CurrentDate),1)))
THEN (Month(CurrentDate) - Month({@BD_Date}))+12
ELSE IF((Date (2000,Month({@BD_Date}),Day({@BD_Date}))) >= (Date (2000,Month(CurrentDate),Day(CurrentDate)))
AND (Date (2000,Month({@BD_Date}),1)) = (Date (2000,Month(CurrentDate),1)))
THEN 0
ELSE (Month({@BD_Date}) - Month(CurrentDate))
if date(year(currentDate), month({myDOB}), day({myDOB})) <= (currentdate) then
// Birthday today or earlier this year
year(currentDate) - year({myDOB}) -1
else
year(currentDate) - year({myDOB})
I've not tested this formula but it should be pretty close. It may cause an error if the DOB is 29th Feb on a leap year so check for that if necessary.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.