Solved! Go to Solution.
input_field = "Date_Time" expression = 'formatDate(!{input_field}!)'.format(input_field=input_field) code_block = """ import dateutil.parser def formatDate(input_date): parsed_date = dateutil.parser.parse(input_date) return parsed_date.strftime("%m/%d/%Y")""" arcpy.AddField_management(input_featureclass, "formatted_output_date", 'DATE') arcpy.CalculateField_management(input_featureclass, field_name, expression, "PYTHON_9.3", code_block)
input_field = "Date_Time" expression = 'formatDate(!{input_field}!)'.format(input_field=input_field) code_block = """ import dateutil.parser def formatDate(input_date): parsed_date = dateutil.parser.parse(input_date) return parsed_date.strftime("%m/%d/%Y")""" arcpy.AddField_management(input_featureclass, "formatted_output_date", 'DATE') arcpy.CalculateField_management(input_featureclass, field_name, expression, "PYTHON_9.3", code_block)