Descriptor 'date' for 'datetime.datetime' objects doesn't apply to a 'int' object

avatar

Borislav Hadzhiev

Last updated: Apr 20, 2022

banner

Photo from Unsplash

Descriptor 'date' for 'datetime.datetime' objects doesn't apply to a 'int' object #

The Python "TypeError: descriptor 'date' for 'datetime.datetime' objects doesn't apply to a 'int' object" occurs when we incorrectly try to use the date class. To solve the error import the datetime module and use the class as datetime.date(2025, 11, 24).

typeerror descriptor date for datetime datetime objects

Here is an example of how the error occurs.

main.py
import datetime # ⛔️ TypeError: descriptor 'date' for 'datetime.datetime' objects doesn't apply to a 'int' object d = datetime.datetime.date(2025, 11, 21)

We incorrectly used the date class in the example.

The date class is directly available in the datetime module.

main.py
import datetime d = datetime.date(2025, 11, 21) print(d) # 👉️ 2025-11-21

The datetime.date class takes the year, month and day as arguments.

Note that all arguments are required and must be in the following ranges:

  • MINYEAR <= year <= MAXYEAR
  • 1 <= month <= 12
  • 1 <= day <= number of days in the given month and year

If an argument is outside the specified ranges, a ValueError is raised.

You can also import the date class from the datetime module.

main.py
from datetime import date d = date(2025, 11, 21) print(d) # 👉️ 2025-11-21

Instead of importing the entire datetime module, we imported only the date class.

This should be your preferred approach because it makes your code easier to read.

For example, when we use an import such as import datetime, it is much harder to see which classes or methods from the datetime module are being used in the file.

It is also quite confusing that there is a datetime class in the datetime module.

If you decide to directly import the date class from the datetime module, make sure to not declare a date variable in your code as that would override the date class.

Conclusion #

The Python "TypeError: descriptor 'date' for 'datetime.datetime' objects doesn't apply to a 'int' object" occurs when we incorrectly try to use the date class. To solve the error import the datetime module and use the class as datetime.date(2025, 11, 24).

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.