12

I'm trying to use dateutil and relativedelta to retrieve the difference between two dates (runwayMonths) but I'm getting TypeError: 'module' object is not callable and can't figure out why.

I assume the issue is with how I'm calling the class and/or module but I can't find a similar example on here or elsewhere that helps me understand what I'm doing wrong.

import datetime
from datetime import timedelta
from dateutil import relativedelta

today = datetime.date.today()
runwayDays = 529
dropDeadDate = today + timedelta(days=runwayDays)
runwayMonths = relativedelta(today,dropDeadDate)

I could understand if I was screwing up the formatting for the parameters for relativedelta as I'm a total noob but the error seems to suggest the issue is with the module or class. Any help would be appreciated!

1 Answer 1

24

dateutil.relativedelta is a module, and the relativedelta() function is inside it.

Try this instead:

from dateutil.relativedelta import relativedelta

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.