Using Python for date calculations

duncan smith buzzard at invalid.invalid
Fri Nov 21 18:03:12 CET 2014

On 21/11/14 08:35, Steve Hayes wrote:
> I've finally found a use for Python. 
> When, in the course of my genealogy research, I look at census or burial
> records, I often want to work out a person's date of birth from their age.
> It's a simple matter of mental arithmetic, but I sometimes get it wrong, and
> mislead myself. There are calculators and date calculation programs, but they
> are usually too complicated and try to do too much, so by the time you've
> worked out what to do it takes much longer. 
> This Python script does it for me. 
> year = input("Year: ")
> age = input("Age: ")
> born = year-age
> print 'Year of birth:', born
> It's so simple, so elementary, that it's not really worth writing about,
> except for the fact that it illustrates the KISS principle. 


This is keeping it too simple. Someone aged 50 (i.e. over 50 but not yet
51) today - 21st Nov 2014 - might have been born in 1963 or 1964
depending on their birthday. For me your calculation would return the
correct answer (born in March), for my sister it would be wrong (born in


More information about the Python-list mailing list