How to find difference in years between two dates?
Bruno Desthuilliers
onurb at xiludom.gro
Wed Jul 26 12:35:20 EDT 2006
John Machin wrote:
> Bruno Desthuilliers wrote:
>
>>John Machin wrote:
>>
>>>Bruno Desthuilliers wrote:
>>
>>>Which pieces of the following seem to be working to you?
>>
>>John, it seems you failed to notice the use of "may" and "seems" in my
>>post. IIRC, both are supposed to strongly suggest a lack of certitude.
>>
>
> I didn't fail to notice that you were seeming. Re-read my question:
> It's asking you which bits you were seeming.
OP problem:
age = (date.today() - born).year
Possible solution:
import mx.DateTime as dt
def age(date):
return dt.Age(dt.today(), date).years
born = dt.Date(1967, 5, 1)
assert age(born) == 39
--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"
More information about the Python-list
mailing list