Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Age calculation based upon date of birth and date of death in years, months and days.

New Here ,
Jun 05, 2021 Jun 05, 2021

Copy link to clipboard

Copied

I'm so sorry if I am asking for the 100th time, but i've searched so many posts and not seeing exactly what I need.  I work for a funeral home and we are now typing our arrangement information instead of hand writing them.  For our obituaries we always have to calculate the final age in years, months and days.  I thought if I could do a script to calculate it for me, it would save some time!  But, I know nothing about scripts in adobe.  Can somebody help me with the code?  My document will have the date of birth field and the date of death field, now I just need to have it calculate in years, months, and days in my age field.  PLEASE HELP!

TOPICS
JavaScript

Views

1.9K

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
community guidelines

correct answers 1 Correct answer

Engaged , Jun 08, 2021 Jun 08, 2021
You have to change: ... if (util.scand("mm/dd/yyyy",this.getField("Deathday").valueAsString)>=util.scand("mm/dd/yyyy",this.getField("Birthday").valueAsString)) { ... var DoB=parseInt(birthday[1]); var MoB=parseInt(birthday[0]); ... var DoD=parseInt(deathday[1]); var MoD=parseInt(deathday[0]); ... That's all for the script. You also have to change the format of both date fields. Remove the script before changing them, else you will have the alert message!!! @+

Likes

Translate

Translate
Adobe Community Professional ,
Jun 05, 2021 Jun 05, 2021

Copy link to clipboard

Copied

What date format will you be using for both date fields? For example, "dd/mm/yyyy".

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
community guidelines
New Here ,
Jun 05, 2021 Jun 05, 2021

Copy link to clipboard

Copied

I am using dd/mm/yyyy.  If it makes it easier, I can split the years, months and days into 3 different sections on the form. 

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
community guidelines
Adobe Community Professional ,
Jun 05, 2021 Jun 05, 2021

Copy link to clipboard

Copied

This might seem like a simple calculation, but it's not. Is it really necessary to show the exact number of days, months and years? Why not just an age in years?

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
community guidelines
New Here ,
Jun 06, 2021 Jun 06, 2021

Copy link to clipboard

Copied

Yes, it is necessary.  We go to websites that have these calculators currently, but trying to save an extra step.

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
community guidelines
Adobe Community Professional ,
Jun 06, 2021 Jun 06, 2021

Copy link to clipboard

Copied

OK, what's the correct result for DOB "31/03/1980" and DOD "01/01/2021"?

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
community guidelines
Engaged ,
Jun 07, 2021 Jun 07, 2021

Copy link to clipboard

Copied

Hi,
I already did something like that some years ago.
Here I've just translated my file.
for DOB "31/03/1980" and DOD "01/01/2021" I find 39 Years, 10 Months and 1 day.
Is it correct for you??
@+

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
community guidelines
New Here ,
Jun 07, 2021 Jun 07, 2021

Copy link to clipboard

Copied

YES, that is exactly what I need!!  Can you give me that script?

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
community guidelines
Adobe Community Professional ,
Jun 07, 2021 Jun 07, 2021

Copy link to clipboard

Copied

The script is in the PDF file.

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
community guidelines
Enthusiast ,
Jun 07, 2021 Jun 07, 2021

Copy link to clipboard

Copied

That script is not accurate.

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
community guidelines
Engaged ,
Jun 07, 2021 Jun 07, 2021

Copy link to clipboard

Copied

How can we have a calculation more accurate with a number of days different in accordance with the month???

@+

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
community guidelines
Enthusiast ,
Jun 07, 2021 Jun 07, 2021

Copy link to clipboard

Copied

If you enter DOB 05/06/2001 and DOD 01/07/2021 you will get 20y 1m and 26days and  result should be 20y 0m and 26days so it's off by 1month.

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
community guidelines
New Here ,
Jun 07, 2021 Jun 07, 2021

Copy link to clipboard

Copied

Thank you!  I was able to get that script to work, but it is off by a day, possibly to account for leap years?  How can we account for this in the script? 

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
community guidelines
New Here ,
Jun 07, 2021 Jun 07, 2021

Copy link to clipboard

Copied

Actually, it is a month off.  If I calculate it with the DOB of 7/6/1927 and the date of death as 6/6/2021, it shows me 94 years and 30 days.  It is actually 93 years and eleven months.

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
community guidelines
Adobe Community Professional ,
Jun 07, 2021 Jun 07, 2021

Copy link to clipboard

Copied

No, @bebarth, that calculation isn’t correct as far as I can see. I’m using this site: Date Duration Calculator: Days Between Dates (timeanddate.com).

  • From and including: Monday, March 31, 1980
  • To and including: Friday, January 1, 2021
  • Result: 14,887 days
  • It is 14,887 days from the start date to the end date, end date included.
  • Or 40 years, 9 months, 2 days including the end date.
  • Or 489 months, 2 days including the end date.

 

@Ashley Akers, have you tried asking a site like this if you can license or purchase a copy of their calculation script (is it javascript?) and then running that script inside Acrobat? Is it the different number of days in each month that makes it too difficult for Acrobat's calculation methods? Is it a custom validation script you need? Which field property would you use?

 

sample-3.jpg

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
community guidelines
Engaged ,
Jun 07, 2021 Jun 07, 2021

Copy link to clipboard

Copied

Hi,

I've just corrected the script.

Let me know if you find any other mistakes.

I'm not sure we have to count the day of the death...

@+

 

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
community guidelines
New Here ,
Jun 07, 2021 Jun 07, 2021

Copy link to clipboard

Copied

It is still off a month.

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
community guidelines
New Here ,
Jun 07, 2021 Jun 07, 2021

Copy link to clipboard

Copied

@bebarthIf I change even the day to reflect one day different, it will change it on the calculation a month versus a day.

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
community guidelines
Engaged ,
Jun 08, 2021 Jun 08, 2021

Copy link to clipboard

Copied

I restarted writing the script from the beginning with the clear ideas of the morning and here is the result.
I did several tests with different dates and all were correct.
Let me know if you still find any mistakes.
I remind you the dates are in format "dd/mm/yyyy".
@+

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
community guidelines
New Here ,
Jun 08, 2021 Jun 08, 2021

Copy link to clipboard

Copied

Thank you!!  Now, how can I change things in order to put the month first versus typing the day?

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
community guidelines
Engaged ,
Jun 08, 2021 Jun 08, 2021

Copy link to clipboard

Copied

You have to change:
...
if (util.scand("mm/dd/yyyy",this.getField("Deathday").valueAsString)>=util.scand("mm/dd/yyyy",this.getField("Birthday").valueAsString)) {
...
var DoB=parseInt(birthday[1]);
var MoB=parseInt(birthday[0]);
...
var DoD=parseInt(deathday[1]);
var MoD=parseInt(deathday[0]);
...
That's all for the script.
You also have to change the format of both date fields. Remove the script before changing them, else you will have the alert message!!!
@+

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
community guidelines
New Here ,
Jun 08, 2021 Jun 08, 2021

Copy link to clipboard

Copied

This worked perfectly!  I can't ever thank you enough for your help!

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
community guidelines
New Here ,
Jul 07, 2021 Jul 07, 2021

Copy link to clipboard

Copied

@bebarthI have another issue with this.  This file that I created to calculate this goes on a couple of computers with adobe reader and not acrobat.  On one computer the file works fine, but the other one, which is a macbook, won't calculate the age but puts in "NaN" in the field.  How can I fix this?  Thanks!

 

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
community guidelines
Adobe Community Professional ,
Jul 08, 2021 Jul 08, 2021

Copy link to clipboard

Copied

LATEST

"NaN" stands for "Not a Number", which means they entered the date in a wrong format, or added some additional text to it, which they shouldn't have.

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
community guidelines
Adobe Community Professional ,
Jun 07, 2021 Jun 07, 2021

Copy link to clipboard

Copied

Also explore this discussion for additional insights:

 

 

In particular, see the contribution provided by NesaNurani about leap year and roll over dates.

 

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
community guidelines