Typeerror: Descriptor 'date' For 'datetime.datetime' Objects Doesn't Apply To A 'int' Object
I've just encountered this issue, and couldn't find a reasonable answer for it on the front page of Google. It's similar to this question asked in 2011, but for a newer version of
Solution 1:
Answer :
importdatetimemy_date= datetime.date(2021, 3, 2)
or
from datetime import date
my_date =date(2021, 3, 2)
Why?
The issue is that datetime.datetime.date() is a method on a datetime.datetime object. We were confusing the datetime module with the datetime.datetime class.
What we're really looking for is the datetime.date() constructor.
Post a Comment for "Typeerror: Descriptor 'date' For 'datetime.datetime' Objects Doesn't Apply To A 'int' Object"