LENGTH( ) function

Returns the number of characters in a string.

Syntax

LENGTH(string)

Parameters

Name Type Description
string character The field, expression, or literal value to find the length of.

Output

Numeric.

Examples

Basic examples

Returns 15:

LENGTH("ABC Corporation")

Returns the length in characters of the Description field in the table layout:

LENGTH(Description)

Advanced examples

Displaying the length of each address in an address field

Create a computed field that displays the length in characters of each address in the Vendor_Street field. Leading and trailing blank spaces are first trimmed from the address values so they are not counted in the length.

DEFINE FIELD Address_Length COMPUTED LENGTH(ALLTRIM(Vendor_Street))

Remarks

How it works

The LENGTH( ) function counts the number of characters in string, including any spaces, and returns the number.

Trailing spaces

Trailing spaces are counted as characters. If you do not want trailing spaces to be counted, use the TRIM( ) or ALLTRIM( ) functions to remove them. For example:

LENGTH(TRIM(Vendor_Street))

If you create a computed field to display the length of the values in a field, and you do not remove trailing spaces, the maximum length of the field is displayed for each value.