Calculate age in months from date of birth to current day

Explorer ,
Apr 12, 2018

Copy link to clipboard

Copied

Hello everyone;

I found the following script (linked below) that worked just fine in calculating the age of the user in years, but I'm having problems customizing it so that it will do the same for months. Even with the little changes that I made, it seems to almost work except that it doesn't show months from 1-11. Case in point, see the screenshot below. At the time of this posting (April 2018), if the Date of Birth is in June, shouldn't the script calculate that the user is 32 years and 10 months old?

screenshot_age.png

I didn't know how to copy/paste code into this post so I took a screenshot of what I had (see below). It is customized (probably horribly) from another script that I found here on Adobe's forums: https://forums.adobe.com/thread/1667044. It may be horrible but something seems to be working on the form, but just not exactly how I need for it to.

screenshot_age-script.png

So, how can I customize the above script to show the user's age in months (I guess in the current year)? So if the user just celebrated a birthday, it would show how many months (in double digits) are left until their next birthday the following year. I hope I explained that right...

I've seen it done in LiveCycle (and implemented it myself - actually on the same form, but the client wanted it on an AcroForm instead). My customization was my best attempt at converting FormCalc into JavaScript and incorporating it into the script that worked for calculating years to the best of my knowledge (which is very little, LOL).

I appreciate all your help.

Ok, here's where I got my FormCalc inspiration from: https://forums.adobe.com/thread/1753485

screenshot_age-script2.png

...if that helps any.

Thanks again

TOPICS
Acrobat SDK and JavaScript, Windows

Views

291

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Calculate age in months from date of birth to current day

Explorer ,
Apr 12, 2018

Copy link to clipboard

Copied

Hello everyone;

I found the following script (linked below) that worked just fine in calculating the age of the user in years, but I'm having problems customizing it so that it will do the same for months. Even with the little changes that I made, it seems to almost work except that it doesn't show months from 1-11. Case in point, see the screenshot below. At the time of this posting (April 2018), if the Date of Birth is in June, shouldn't the script calculate that the user is 32 years and 10 months old?

screenshot_age.png

I didn't know how to copy/paste code into this post so I took a screenshot of what I had (see below). It is customized (probably horribly) from another script that I found here on Adobe's forums: https://forums.adobe.com/thread/1667044. It may be horrible but something seems to be working on the form, but just not exactly how I need for it to.

screenshot_age-script.png

So, how can I customize the above script to show the user's age in months (I guess in the current year)? So if the user just celebrated a birthday, it would show how many months (in double digits) are left until their next birthday the following year. I hope I explained that right...

I've seen it done in LiveCycle (and implemented it myself - actually on the same form, but the client wanted it on an AcroForm instead). My customization was my best attempt at converting FormCalc into JavaScript and incorporating it into the script that worked for calculating years to the best of my knowledge (which is very little, LOL).

I appreciate all your help.

Ok, here's where I got my FormCalc inspiration from: https://forums.adobe.com/thread/1753485

screenshot_age-script2.png

...if that helps any.

Thanks again

TOPICS
Acrobat SDK and JavaScript, Windows

Views

292

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Apr 12, 2018 0
Explorer ,
Apr 12, 2018

Copy link to clipboard

Copied

Ok, here's where I got my FormCalc inspiration from: https://forums.adobe.com/thread/1753485

screenshot_age-script2.png

...if that helps any.

Thanks again

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 12, 2018 0