Ho do I calculate "Today - DOB = age in years" in a PDF?
I have found a Script that caluates age into months however I need age in years. How do I change the below script?
var cDateFormat = "dd-mmm-yyyy";
var cDate = this.getField("dob").value;
if(cDate != "") {
var oDate = util.scand(cDateFormat, cDate);
}
if(oDate == null) app.alert("Invalid date: " + cDate, 1, 0);
else {
var now = new Date();
var nMonth = Number(now.getMonth());
var nYear = Number(now.getFullYear());
var diffYear = nYear - oDate.getFullYear();
var diffMonth = nMonth-oDate.getMonth();
if (diffYear) {
diffYear = diffYear * 12;
}
event.value = diffMonth + diffYear;
}