Using Python for date calculations

Paul Blair p.blair at internode.on.net
Fri Nov 21 14:51:15 EST 2014


On 22-Nov-2014 6:35 am, Dennis Lee Bieber wrote:
> On Fri, 21 Nov 2014 10:35:19 +0200, Steve Hayes <hayesstw at telkomsa.net>
> declaimed the following:
>
>
>> 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.
>>
> 	And it is wrong since it doesn't take into account the month.
>
> 	2014 - 55 => 1959
>
> 	But I was born in April of 1958, so any calculation done for
> January/February/March (and the first week of April) is going to produce
> the incorrect year (I /was/ 55 in January of 2014...)
>
> --
> 	bieber.genealogy at earthlink.net		Dennis Lee Bieber	
> 	HTTP://home.earthlink.net/~bieber.genealogy/
>

Have a read of:

http://stackoverflow.com/questions/2217488/age-from-birthdate-in-python

Paul



More information about the Python-list mailing list