Created
February 22, 2019 13:08
-
-
Save waltertschwe/70ac1c7a6fdf9e18c6e77c7b05385770 to your computer and use it in GitHub Desktop.
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 | |
| date_string = '2019-01-22' | |
| date_format = '%Y-%m-%d' | |
| try: | |
| date_obj = datetime.datetime.strptime(date_string, date_format) | |
| print(date_obj.date()) | |
| except ValueError: | |
| ## pass 400 error here incorrect date format message | |
| print("Incorrect data format, should be YYYY-MM-DD") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment