Calculating Year, Month and Day of Life

Dan Bishop danb_83 at yahoo.com
Sat Jul 5 18:51:20 EDT 2003


hokiegal99 <hokiegal99 at hotmail.com> wrote in message news:<be72ph$k60$1 at solaris.cc.vt.edu>...
> Hello,
> 
> I am a funeral director trying to write a small program that calculates 
> the number of years, months and days a person has lived by entering the 
> year, month and day of their birth. This is what I have so far:

How do you calculate the years, months, and days?  For your example
(born: 1934-02-07, died: 2003-07-05), I can think of at least 3
plausible results.

Method 1 (counting forward):
* This person was 69 years old on their last birthday.
* 4 months after their last birthday, it was June 7.
* There were 23 days left in June,
* and 5 days in July until the date of death.
* So this person lived for 69 years, 4 months, and 28 days.

Method 2 (counting backward):
* 69 years before death was 1934-07-05.
* 4 months earlier was March 5.
* 5 days earlier was February 28,
* when the person was 21 days old.
* This person lived for 69 years, 4 months, and 26 days.

Method 3 (day counts):
* date of birth = R.D. 706051
* date of death = R.D. 731401
* This person lived for 25350 days.
* There are an average of 30.436875 days in a month.
* So 25350 days = 832 months + 26.52 days
* 832 months = 69 years + 4 months
* 26.52 days rounds to 27
* This person lived for 69 years, 4 months, and 27 days.




More information about the Python-list mailing list