Skip to main content
Ashley Akers
Known Participant
June 6, 2021
해결됨

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

  • June 6, 2021
  • 3 답변들
  • 19195 조회

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!

이 주제는 답변이 닫혔습니다.
최고의 답변: bebarth

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


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!!!
@+

3 답변

ls_rbls
Community Expert
Community Expert
June 8, 2021

Also explore this discussion for additional insights:

 

 

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

 

try67
Community Expert
Community Expert
June 6, 2021

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?

Ashley Akers
Ashley Akers작성자
Known Participant
June 6, 2021

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

bebarth
Community Expert
Community Expert
June 7, 2021

No, @5833724, 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?

 


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...

@+

 

Inspiring
June 6, 2021

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

Ashley Akers
Ashley Akers작성자
Known Participant
June 6, 2021

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.