Skip to main content
Participating Frequently
February 6, 2020
Question

Calculate Age in Years AND Months from Date of Birth

  • February 6, 2020
  • 3 replies
  • 3147 views

I am needing to calculate the age in years and months from a date of birth field. The date of birth is in MM/DD/YYYY format. My date of birth field is called "Date of Birth" I am new to Adobe and coding so I appreciate any help. 

This topic has been closed for replies.

3 replies

Thom Parker
Community Expert
Community Expert
February 6, 2020

Date and time calculations are more difficult that regular calculations because dates and times have a complex relationship. So you need to work a bit harder to script them.

You can read about working with dates and times here:

Working with date and time in Acrobat JavaScript - Part 1 of 3

Working with date and time in Acrobat JavaScript - Part 2 of 3

Working with date and time in Acrobat JavaScript - Part 3 of 3

https://www.pdfscripting.com/members/Date-and-Time-Handling.cfm

 

Let us know when you've worked up a rough script and we can help you refine it.

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
lembrooksAuthor
Participating Frequently
February 6, 2020

Thank you. I have worked up a few scripts that I haven't been able to work so I will post them a little later. 

Thom Parker
Community Expert
Community Expert
February 6, 2020

Are you trying out your scripts first in the Console Window? This is the best place to try out scripting ideas, to find out what works.

You'll find a tutorial for it here:

https://www.pdfscripting.com/public/Free_Videos.cfm#JSIntro

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
try67
Community Expert
Community Expert
February 6, 2020

Try searching the forum. This issue was discussed here many times and there are full codes posted for it.

lembrooksAuthor
Participating Frequently
February 6, 2020

Wow thank you for the helpful post. I have searched several threads and have not found one that has worked. Most of the threads have had other stipulations that I do not need. I've also struggled with substituting my "Date of Birth" field rather than the field titles others are using. 

lembrooksAuthor
Participating Frequently
February 6, 2020

I should add that I want it to say "years" and "months" after the corresponding number of years and months