date_object = datetime.datetime.strptime(date_str, format_str).date()
This is because the strptime() function generates a Python datetime object.
3. In Option 3: your format pattern is not correct. Instead of '%d-%M-%Y' it should be '%d-%m-%Y'
4. Option 2 provides no support for the handling of empty strings or Null values. In Option 3 you provided support for empty strings but not for Null values.
So, below is my version of the code:
#### ConfigureFields Script ####
out1 += in1
out1.new_date = datetime.date
format_str = '%d-%m-%Y' # The format
#### End of ConfigureFields Script ####
#### ProcessRecordsScript ####
out1 += in1
if in1['eas_Factuur datum'] == '' or fields['eas_Factuur datum'] == Null:
out1.new_date = Null
else:
out1.new_date = datetime.datetime.strptime(fields['eas_Factuur datum'], format_str).date()
#### End of ProcessRecordsScript ####
Note, as the format_str is a constant value for all records it was defined in the ConfigureFields script.
A final general comment - rather than editing your original post, if you have additional information it is better to add a new comment. Thanks.