Skip to content

Python code snippet – How to compare current date to future date o?

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")
See also  How to separate date and time in Python?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.