We Are Going To Discuss About TypeError: descriptor ‘date’ for ‘datetime.datetime’ objects doesn’t apply to a ‘int’ object. So lets Start this Python Article.
TypeError: descriptor ‘date’ for ‘datetime.datetime’ objects doesn’t apply to a ‘int’ object
- How to solve TypeError: descriptor 'date' for 'datetime.datetime' objects doesn't apply to a 'int' object
Solution:
import datetime my_date = datetime.date(2021, 3, 2)
orfrom datetime import date my_date = date(2021, 3, 2)
Why?
The issue is thatdatetime.datetime.date()
is a method on adatetime.datetime
object. We were confusing thedatetime
module with thedatetime.datetime
class.
What we're really looking for is thedatetime.date()
constructor. - TypeError: descriptor 'date' for 'datetime.datetime' objects doesn't apply to a 'int' object
Solution:
import datetime my_date = datetime.date(2021, 3, 2)
orfrom datetime import date my_date = date(2021, 3, 2)
Why?
The issue is thatdatetime.datetime.date()
is a method on adatetime.datetime
object. We were confusing thedatetime
module with thedatetime.datetime
class.
What we're really looking for is thedatetime.date()
constructor.
Solution 1
Solution:
import datetime
my_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.
Original Author edited Jun 9, 2021 at 3:58 Of This Content
Conclusion
So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.