>>> from datetime import datetime as dt
>>> a = dt.strptime("10/12/13", "%m/%d/%y")
>>> b = dt.strptime("10/15/13", "%m/%d/%y")
>>> a > b
False
>>> a < b
True
>>>
jan_1_2020 = datetime.datetime(2020, 1, 1)
dec_12_2020 = datetime.datetime(2020, 12, 12)
if (jan_1_2020 < dec_12_2020):
print("first datetime is less than the second")
jan_1_2020 = datetime.datetime(2020, 1, 1)
dec_12_2020 = datetime.datetime(2020, 12, 12)
if (jan_1_2020 < dec_12_2020):
print("first datetime is less than the second")
datatime, comparison of time python,compare time python
>>> a
datetime.datetime(2009, 12, 2, 10, 24, 34, 198130)
>>> b
datetime.datetime(2009, 12, 2, 10, 24, 36, 910128)
>>> a < b
True
>>> a > b
False
>>> a == a
True
>>> b == b
True
>>>