Age Beside Death Date
I would like to see, when I'm viewing a person's dossier, under the "Vitals" section, to the right of the death date, the person's age at death.
Comments
-
Now I will add some details, for two reasons. First, we should all be aware that some little function like this looks as easy as falling off a log, but it's actually quite complicated; we should go easy on the peeps doing the work. Second, this is something a manager will typically hand to a junior programmer, so for that guy's benefit I'll run thru it. Thirdsies, anybody doing genealogy needs to know this.
Also, I'm going to make a deliberate math error just for fun; see if you can find it. I like to provide value!
When working with dates and ages, you compute a difference by subtracting. Let's say a person was born in 1845 and died in 1904, July 5th. The "quick and dirty" way is to just subtract the later (larger) year minus the earlier (smaller): 59 years old.
But to do it right, you express each date as year, month, day then subtract.
died 1904 07 05
born 1845
But here, what do we do with 1845? We don't know the month or day. The correct way to do it is to break both dates out as ranges. 1845 is really a range, 1845 jan 1 to 1845 dec 31. The death date is also a range, both ends of the range being the same day.
1904 07 05 -> 1904 07 05
1845 01 01 -> 1845 12 31
Starting at the far right, 5 minus 31 doesn't work so borrow a month (assume 30 days for simplicity, but you could consult a table. July is easy but February is complex; but it can be done. Every 4 years, Feb has 29 days, except every 100 years it doesn't; except every 400 years it DOES.) So now you have 5 plus 31 is 36 minus 31 leaves 5. Then same thing for 7 (now 6) minus 12, you borrow a year of 12 months so 18 minus 12 leaves 6. Then 1903 minus 1845 leaves 58. On the left side we do the same but no borrow needed and get 59 years, 6 months, 4 days. So the guy's age is
59 06 04 -> 58 06 04
You want to swap them, put the older age on the right. If you just want it in years, it's 58 or 59 years old. So the simple answer of 59 is only approximately right.
0 -
It's not quite as convenient as the Vitals box, but you could just look at the person's Time Line tab.
(I majored in mathematics so that I could forever avoid doing arithmetic, so I regretfully decline your puzzle.)
0 -
You don't address people where all you can prove is they were born before or after a certain date or died before or after a certain date.
0 -
I should address the error. Let's consider dossier K1T8-GCY (John Swain), born 1805 died 1860, no months or days given. If we do the subtraction as I outlined, we get these ranges:
died 1860 01 01 -> 1860 12 31
born 1805 01 01 -> 1805 12 31
age 55 00 00 55 00 00
Age = exactly 55. This is incorrect. The minimum age is found by subtracting the latest possible birth from the earliest possible death, and the maximum age, vice versa.
died 1860 01 01 -> 1860 12 31
born 1805 12 31 -> 1805 01 01
age 54 00 01 -> 55 11 30
And what does the timeline say? Age 55. It would be more accurate to say age 54-56, or or 55+/-1, or to fit just one more char in there, age 55~ or even "age 55?"
All of the dates there are calculated in this "quick and dirty" fashion.
By the way, there's ANOTHER math error in the above. If a baby is born on Dec. 31 and dies on Jan 1, we say they were less than a day old or 1 day old depending on the hour. So Grampa John here's age range is a day off. Should be 54 00 00 -> 55 11 30.
0