0 # Getting the Year & Month between two dates

I created a convoluted formula to calculate the age of a student at the start of a course. The basic idea is 'Course Start Date' - 'Student Birthdate'

I was hoping someone could give me some pointers how to simplify my formula as I have a hard time believing this is an efficient way of doing this.

`year(Classes.Terms.'Term Start Date') - year(Students.Birthdate) - if month(Classes.Terms.'Term Start Date') < month(Students.Birthdate) then1elseif month(Classes.Terms.'Term Start Date') = month(Students.Birthdate) and day(Classes.Terms.'Term Start Date') < day(Students.Birthdate) then1else0endend + "y " + if month(Classes.Terms.'Term Start Date') < month(Students.Birthdate) and day(Classes.Terms.'Term Start Date') >= day(Students.Birthdate) thenmonth(Classes.Terms.'Term Start Date') + 12 - month(Students.Birthdate)elseif month(Classes.Terms.'Term Start Date') > month(Students.Birthdate) and day(Classes.Terms.'Term Start Date') < day(Students.Birthdate) thenmonth(Classes.Terms.'Term Start Date') - 1 - month(Students.Birthdate)elseif month(Classes.Terms.'Term Start Date') < month(Students.Birthdate) and day(Classes.Terms.'Term Start Date') < day(Students.Birthdate) thenmonth(Classes.Terms.'Term Start Date') + 11 - month(Students.Birthdate)elsemonth(Classes.Terms.'Term Start Date') - month(Students.Birthdate)endendend + "m"`

18replies Oldest first
• Oldest first 