Skip to content

Instantly share code, notes, and snippets.

@harsha89
Created May 7, 2020 05:22
Show Gist options
  • Save harsha89/925ae238a080dc06e82d354fbc0bd41c to your computer and use it in GitHub Desktop.
Save harsha89/925ae238a080dc06e82d354fbc0bd41c to your computer and use it in GitHub Desktop.
Compare two dates python
from datetime import datetime
def compare_dates(date):
dateFrom = datetime.strptime('01/02/2020', "%d/%m/%Y")
dateTo = datetime.strptime('30/04/2020', "%d/%m/%Y")
dateIn = datetime.strptime(date, "%Y-%m-%d")
if dateIn >= dateFrom and dateIn < dateTo:
return True
else:
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment