Copy link to clipboard
Copied
Hi Team,
I am after a script to workout a persons age based on their date of birth. the dob field is called DOB and i use dd/mmm/yyyy
TIA
Copy link to clipboard
Copied
Hi Ben
Hope you are doing well and sorry for the trouble.
The workflow you are trying to achieve is possible using the JavaScript. For more information please check out the help page https://acrobatusers.com/tutorials/javascript_console/
Hope it will help
Regards
Amal
Copy link to clipboard
Copied
Copy link to clipboard
Copied
not sure how to make it work for my needs though
Copy link to clipboard
Copied
Try use this as "Custom calculation script" in field where you want to show age:
event.value = "";
var dv = this.getField("DOB").value;
if (dv!="") {
var dob = util.scand("dd/mmm/yyyy", dv);
var today = new Date();
var age = today.getFullYear() - dob.getFullYear();
if (today.getMonth() < dob.getMonth()) age = age - 1;
if ((today.getMonth() == dob.getMonth()) && (today.getDate() < dob.getDate())) age -= 1;
event.value = age;}
Copy link to clipboard
Copied
This issue was discussed on the forums many times, including complete code examples of how to do it. Try searching around a bit of "age calculation" or similar keywords...