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!
dateutil.relativedelta
is a module, and the relativedelta()
function is inside it.
Try this instead:
from dateutil.relativedelta import relativedelta
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With