Last active
July 6, 2016 10:38
-
-
Save brettfreer/4865ba9f7ed9b5946107eecf081d01bd to your computer and use it in GitHub Desktop.
Validate if a text string is a valid date with a supplied format string
This file contains hidden or 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
import datetime | |
def isDate(date_text, fmt): | |
try: | |
datetime.datetime.strptime(date_text, fmt) | |
except ValueError: | |
return False | |
return True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment