>>> 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
>>>
datetime.datetime.strptime(str(datetime.date.today()), "%Y-%m-%d") >= datetime.datetime.strptime("2022-10-22", "%Y-%m-%d")
import datetime
today = datetime.date.today()
tomorow = today + datetime.timedelta(days=1)
1dayTimedelta = today - tomorow
result = 1dayTimedelta.total_seconds()
#the difference in seconds
>>> from datetime import datetime, timedelta
>>> past = datetime.now() - timedelta(days=1)
>>> present = datetime.now()
>>> past < present
True
>>> datetime(3000, 1, 1) < present
False
>>> present - datetime(2000, 4, 4)
datetime.timedelta(4242, 75703, 762105)
jan_1_2020 = datetime.datetime(2020, 1, 1)
dec_12_2020 = datetime.datetime(2020, 12, 12)
if (jan_1_2020 < dec_12_2020):
# ...
# More examples are at https://docs.python.org/3/library/datetime.html
# If you convert all your date to `datetime.date`, you can write the following:
if start <= date <= end:
print("in between")
else:
print("No!")
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")