SUB

Use this function to return a substring from a string at a specified position.

Syntax

SUB (String, Position, Length)

Parameter

Description

String

Enter a valid string. The default is the current field.

Position

Enter the position where sub should begin. The default is one (1).

Length

Enter the length to retrieve from the text. The default is the length of what remains of the String parameter value, beginning at the position indicated by the Position parameter.

The system returns a portion of the first specified parameter starting at the specified position for the length given.

If you omit the Position parameter, the system defaults to the first character of the string. If the specified position is greater than the length of the string, the system returns an empty result.

If you omit the Length parameter, the remainder of the string following the specified position is included.

Example

Here are some examples:

(Assume the current field contains the text Your Name.)

Function

Result

Explanation

SUB ( , , 5)

"Your "

Defaults to position one of the current field and returns the first five characters.

SUB ( )

"Your Name"

Defaults to the current field; No length was specified, so the field remains the same.

SUB ("Complete Street Address", 10, 6)

"Street"

Goes to position 10 of the specified field and returns six characters.

See also