Consider this code:
datestring = date.min.strftime("%d-%m-%Y")
date = datetime.strptime(datestring,"%d-%m-%Y")
This raises the following error:
Traceback (most recent call last): File "D:/Dev/foo.py", line 37, in <module>
datestring = date.min.strftime("%d-%m-%Y") ValueError: year=1 is before 1900; the datetime strftime() methods require year >= 1900
Why is the min date not 1900 then???
I’m using storing date.min in the init of a class as to set it to an empty date sortof. When I persist this to the sqlite database, I do not have a Null date this way.
I do this because when I read back an empty date from the db, it raises an error in dbapi2.py in the convertdate function
How do you guys solve this?
this is not the problem with
date.minordatetimemodule, problem is due to platform-specific weirdnesses in implementations ofstrftimesee http://bugs.python.org/issue1777412
A work around would be to set a
date_min > 1900or just use a hand crafted string for your default date value