2

I am trying to use LEN to select all strings in a Column that are a length of a phone number, and am unable to enter the correct expression, is it possible to use LEN in SelectLayerByAttribute_management ?

arcpy.SelectLayerByAttribute_management("Contacts_tbl", "NEW_SELECTION", "LEN(Contact_Phone_Work) = 12")

1 Answer 1

6

Yes, you're looking for CHAR_LENGTH

CHAR_LENGTH(string_exp)

Returns the length in characters of the string expression.

arcpy.SelectLayerByAttribute_management("Contacts_tbl",
                                        "NEW_SELECTION",
                                        "CHAR_LENGTH(Contact_Phone_Work) = 12")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.