>> a ='2009-05-10'
>>> b ='2009-06-10'
>>> a > b
False
>>> a < b
True
>>> type(a)
<class 'str'>
>>> c = '2009-06-09'
>>> b < c
False
>>> b > c
True
>>> c ='2008-07'
>>> b > c
True
>>> a > c
True
I tried to compare dates in python3 without using a library and it seems to be working correctly. Is this the real case? Does python really understands that these strings are dates and comparing them according to date format or is something else is going on behind the scenes ?
YYYYMMDDand lets lexicographical sorting take care of the rest. The dates are not parsed or validated.