[Tutor] Use of dateutil.relativedata

Etrade Griffiths etrade.griffiths at dsl.pipex.com
Wed Nov 15 15:29:20 CET 2006


Hi

trying to use dateutil to calculate the number of months between two 
dates.  here is the script

import datetime
import dateutil

x=datetime.date.today()
y=x+datetime.timedelta(days=366)
z=y-x

print x,y,z

a=dateutil.relativedelta(x,y)
print a


and here is the output

 >>>
2006-11-15 2007-11-16 366 days, 0:00:00

Traceback (most recent call last):
   File "C:/Projects/completion_dates", line 10, in -toplevel-
     a=dateutil.relativedelta(x,y)
AttributeError: 'module' object has no attribute 'relativedelta'
 >>>

There's problem here that's really basic but just can't see it!!!

Thanks

Alun Griffiths 




More information about the Tutor mailing list