zinon zinon - 3 months ago 27
Python Question

Django date format issue using strptime().date

I'm using django 1.8 in python 2.7

My code is

(datetime.strptime('diagnosis_circumstances_date', "%Y-%m-%d")).date()

and us a result I get
time data 'diagnosis_circumstances_date' does not match format '%Y-%m-%d'

My date is


You should use the variable diagnosis_circumstances_date, not the string 'diagnosis_circumstances_date'.

datetime.strptime(diagnosis_circumstances_date, "%Y-%m-%d")).date()