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.

try67
Community Expert
Community Expert
June 6, 2021

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

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.