PROBLEM

Running the Calculate Field tool with Date and Text data type in a Python expression fails and returns Error 000539

Last Published: December 2, 2021

Description

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
The error message is returned when attempting to run the Calculate Field tool.

Cause

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.

The date field (SurveyDate) is used as the second parameter instead, and the text field (Errors) is used as the first parameter in the Python expression.

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 Arcade function is used to return the required statement in the Status field based 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.

The Calculate Field tool runs successfully, and returns the desired results in the Status field.

Article ID:000026884

Software:
  • ArcGIS Pro 2 8 x
  • ArcGIS Pro 2 x

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Related Information

Discover more on this topic