How to find difference in years between two dates?

thebjorn bp.datakortet.no at gmail.com
Thu Jul 27 14:22:13 EDT 2006


Bruno Desthuilliers wrote:
> 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 ?

All input routines, whether they're from a web-form, database, command
line, or anywhere else, only produce objects from the datetime module
for calendar data. That way the program logic doesn't have to guess
which format it's getting... I suppose I could do something like:

   def age(born):
        mx_born = mx.DateTime.Date(born.year, born.month, born.day)
        ...

-- bjorn




More information about the Python-list mailing list