# Help : Calculating Ages 2

I need help calculating ages from an array of Students Details.
The ages are read in by YEAR / MONTHS and at the moment i am using

*NOT CODE
For i = 1 to Number of Students
total = total+(CurrentStudent Months)+ (CurrentStudent Years * 12)
CurrentStudent.MoveNext
Next i
Average Age = (total / 12) / Number of Students

However the result of average age gives me someting like 4.5 years
when i want is the result in Years / Months 4 Years and 6 Months

Anyhelp would be greatly accepted

JJ

• : I need help calculating ages from an array of Students Details.
: The ages are read in by YEAR / MONTHS and at the moment i am using
:
: *NOT CODE
: For i = 1 to Number of Students
: total = total+(CurrentStudent Months)+ (CurrentStudent Years * 12)
: CurrentStudent.MoveNext
: Next i
: Average Age = (total / 12) / Number of Students
:
: However the result of average age gives me someting like 4.5 years
: when i want is the result in Years / Months 4 Years and 6 Months
:
: Anyhelp would be greatly accepted
:
: JJ
:

Simply take the decimal portion and multiply it by 12 to get the number of months.

Note: If you open your own post, you will see both an edit and a delete link. Please use them instead of making multiple posts. I deleted the other one for you.
• Here's what you need to do to get the months and years separated

[code]
AverageAge = total / NumberOfStudents
AverageYearPortion = Int(AverageAge / 12)
AverageMonthPortion = Int(AverageAge - (AverageYearPortion * 12))
AverageDayPortion = (AverageAge - (AverageYearPortion * 12) - AverageMonthPortion) * 30
[/code]

[purple]Melissa[/purple]