@lisamthorpe OK, you need to adjust your function to something like this:
function getAge(dateString, programDate) {
var birthDate = new Date(dateString);
var age = programDate.getFullYear() - birthDate.getFullYear();
var m = programDate.getMonth() - birthDate.getMonth();
if (m < 0 || (m === 0 && programDate.getDate() < birthDate.getDate())) {
age--;
}
return age;
}
Disclaimer: I haven’t test this, but that’s the general idea.