Reputation: 11
The below python code worked fine until 12-31-9999.
It threw error once I changed the date to 01-01-10000 (see the screen shot attached)
from datetime import datetime
import time
myNewDate = "12-31-9999"
myNewDateTime = datetime.strptime(myNewDate, '%m-%d-%Y').date()
print (myNewDateTime)
Here is the screen shot:
Upvotes: 1
Views: 708
Reputation: 26954
According to the docs, only 4 digit years are supported.
The years are limited by the 1989 C standard.
Upvotes: 3
Reputation: 2816
%Y
signifies a 4 digit year, the last 0 is unmatched by the pattern. You can't use python datetime to work with years beyond 9999: https://docs.python.org/3/library/datetime.html#datetime.MAXYEAR
Upvotes: 1