Problem: Running the Calculate Field tool with Date and Text data type in a Python expression fails and returns Error 000539
In ArcGIS Pro, attempts to run the Calculate Field tool when using Python expressions with the date field as the first parameter and the text field as the second parameter fail. The following error message is returned:
Error: ERROR 000539: File "", line 1 method(GPVARIANTOBJECT0, attribute1 ) ^ SyntaxError: invalid syntax
This is a known limitation, when the order of date followed by text fields combination is used as parameters in the Python expressions in ArcGIS Pro.
Solution or Workaround
Use one of the methods below to resolve the issue.
Use the text field as the first parameter
In ArcGIS Pro, reverse the order of the parameters in the Python expressions. In this example, the text field, Errors, is used as the first parameter, and the date field, SurveyDate, is used as the second parameter.
Use Arcade expression
Refer to ArcGIS Arcade: Getting Started for more information. In this example, the Arcade function is used to return the required statement in the Status field, depending on the attribute values in the SurveyDate field.
The following image demonstrates the Calculate Field tool has run successfully, and the desired result is returned in the Status field.
Last Published: 12/1/2021
Article ID: 000026884
Software: ArcGIS Pro 2.9, 2.8.3, 2.8.2, 2.8.1, 2.8