Using Python for date calculations

Steve Hayes hayesstw at telkomsa.net
Fri Nov 21 20:48:24 CET 2014


On Fri, 21 Nov 2014 17:03:12 +0000, duncan smith <buzzard at invalid.invalid>
wrote:

>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. 
>> 
>
>[snip]
>
>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
>December).

So it might be a year out in the case of burials, nut in the case of many
censuses they would be more likely to have been born the year before, since
most censuses are taken i8n tyhe first part of the year. So the calculation is
a rough one, but that's all I need. If sommeone is 20 in the 1871 census, I'd
put them down as born about 1850, which probably has a 65% chance o0f being
right. 


-- 
Steve Hayes from Tshwane, South Africa
Web:  http://www.khanya.org.za/stevesig.htm
Blog: http://khanya.wordpress.com
E-mail - see web page, or parse: shayes at dunelm full stop org full stop uk



More information about the Python-list mailing list