Created
May 7, 2020 05:22
-
-
Save harsha89/925ae238a080dc06e82d354fbc0bd41c to your computer and use it in GitHub Desktop.
Compare two dates python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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