How to show an average age with this code

The AGE formula below I found from another posting and tweaked it for my report. The enduser will love how it shows Yrs and Months BUT because I wasn’t sure how to calculate an average age off of it I created AGE2 formula and created AVGAGE to calculate average age but I don’t want it to display as 33.99 but as 33y/11m.

How do I do this? :hb: I know the answer is right in front of me but the AGE formula is not something I’ve written. HELP!

AGE
Local BooleanVar CfDayValues := IF ((Month ({PAEMPLOYEE.BIRTHDATE}) * 100) + Day ({PAEMPLOYEE.BIRTHDATE})) IN [131, 229, 331, 531, 731, 831, 1031, 1231] AND ((Month (PrintDate) * 100) + Day (PrintDate)) IN [228, 430, 630, 930, 1130] THEN False
ELSE
(DateTime (1920, 01, Day (PrintDate))) < (DateTime (1920, 01, Day ({PAEMPLOYEE.BIRTHDATE})));
Local BooleanVar CfMoValues :=
(DateTime (1920, Month (PrintDate), 01)) < (DateTime (1920, Month ({PAEMPLOYEE.BIRTHDATE}), 01));
Local NumberVar CfDay := IIF (CfDayValues, 1, 0);
Local NumberVar CfMonth := IIF (CfMoValues, 1, 0);

Local NumberVar AgeMonths := (DateDiff(‘m’, {PAEMPLOYEE.BIRTHDATE}, PrintDate) - CfDay) Mod 12;
Local NumberVar AgeYrs := DateDiff(‘yyyy’, {PAEMPLOYEE.BIRTHDATE}, PrintDate) - CfMonth;
Local StringVar YrsMos := ToText(AgeYrs, 0) + ‘y/’ + ToText(AgeMonths, 0) + ‘m’;

YrsMos;

AGE2
DATEDIFF(“d”,{PAEMPLOYEE.BIRTHDATE},PrintDate)/365

AVGAGE
Average ({@AGE2}, {PROCLEV.R_NAME})

Thank you,

Sarah


scotton (BOB member since 2011-07-15)