AttributeError: ‘method_descriptor’ object has no attribute ‘today’ | Python | Way to Solve

Table of Contents

Error

AttributeError: ‘method_descriptor’ object has no attribute ‘today’

Our Python Code is :

from datetime import datetime
from dateutil import relativedelta
nextmonth = datetime.date.today() + relativedelta.relativedelta(months=1)
print(nextmonth)

Solution

Two ways to overcome this error:

(i) – Instead of writing “from datetime import datetime” , just write “import datetime” , like:

import datetime
from dateutil import relativedelta
nextmonth = datetime.date.today() + relativedelta.relativedelta(months=1)
print(nextmonth)

(ii) – Instead of importing datetime and accessing “date” from “datetime” , directly import “date” ,like:

from datetime import date
from dateutil import relativedelta
nextmonth = date.today() + relativedelta.relativedelta(months=1)
print(nextmonth)