Skip to content Skip to sidebar Skip to footer

What Is The Range Of Valid Dates For The Datetime Module?

I'm playing with the Python datetime module. I'm using it to determine the day of the week for a given date. Python conveniently raises a ValueError when the date is invalid; e.g.,

Solution 1:

Check date.min and date.max:

>>> from datetime import date
>>> date.min
datetime.date(1, 1, 1)
>>> date.max
datetime.date(9999, 12, 31)

Post a Comment for "What Is The Range Of Valid Dates For The Datetime Module?"