How to find difference in years between two dates?
Bruno Desthuilliers
onurb at xiludom.gro
Thu Jul 27 03:12:02 EDT 2006
thebjorn wrote:
> Bruno Desthuilliers wrote:
> [...]
>
>>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
>
>
> dealbreaker:
>
>>>>age(datetime.date(1970,5,2))
>
(snip traceback)
What about:
age(dt.Date(1970,5,2))
> I'm getting data from a database, and conversions
> are out of the
> question for something like this.
Which conversion ? How do you get the data ? as a datetime object ? as a
(y,m,d) tuple ? as a "y-m-d" string ? Else ?
--
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