datetime.now date comparison python code example
Example 1: python datetime compare
date1 = datetime.date(2014, 3, 2)
date2 = datetime.date(2013, 8, 1)
was_date1_before = date1 < date2
Example 2: phyton datetime comparison
# date in yyyy/mm/dd format
d1 = datetime.datetime(2018, 5, 3)
d2 = datetime.datetime(2018, 6, 1)
# Comparing the dates will return
# either True or False
print("d1 is greater than d2 : ", d1 > d2)