Below javascript function will calculate age from 2 date values. Remember date values should be in DD/MM/YYYY format.
function CalculateAge(TodaysDate,NewDate)
{
var day1 = parseInt(TodaysDate.substring(0,2),10);
var mon1 = parseInt(TodaysDate.substring(3,5),10);
var yr1 = parseInt(TodaysDate.substring(6,10),10);
var day2 = parseInt(NewDate.substring(0,2),10);
var mon2 = parseInt(NewDate.substring(3,5),10);
var yr2 = parseInt(NewDate.substring(6,10),10);
var diff1 = parseInt(yr1 - yr2);
var diff2 = parseInt(mon1 - mon2);
var diff3 = parseInt(day1 - day2);
if(diff2 <0)
{
diff1 = diff1-1;
diff2 = diff2+12;
}
if(diff3 <0)
{
diff2 = diff2-1;
if(diff2<0)
{
diff1 = diff1-1;
diff2 = diff2+12;
}
}
var strAge = diff1+"."+diff2;
return parseFloat(strAge);
}
For more details please
refer this link.