The function to get a datetime from a string, datetime.strptime(date_string, format) requires a string format as the second argument. Is there a way to build a
Can get away with a simple function if only checking against dates.
def get_date(s_date):
date_patterns = ["%d-%m-%Y", "%Y-%m-%d"]
for pattern in date_patterns:
try:
return datetime.datetime.strptime(s_date, pattern).date()
except:
pass
print "Date is not in expected format: %s" %(s_date)
sys.exit(0)