python datetime compare dates 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: how to compare current date to future date pythono

import datetime

CurrentDate = datetime.datetime.now()
print(CurrentDate)

ExpectedDate = "9/8/2015 4:00"
ExpectedDate = datetime.datetime.strptime(ExpectedDate, "%d/%m/%Y %H:%M")
print(ExpectedDate)

if CurrentDate > ExpectedDate:
    print("Date missed")
else:
    print("Date not missed")