LEFT( ) Function

Returns a specified number of characters from a character expression, starting with the leftmost character.

LEFT(cExpression, nExpression)

Parameters

  • cExpression
    Specifies the character expression that LEFT( ) returns characters from.

  • nExpression
    Specifies the number of characters returned from the character expression. If nExpression is greater than the length of cExpression, all of the character expression is returned. If nExpression is negative or 0, LEFT( ) returns an empty string.

    LEFT( ) uses a starting position of 1 and is identical to SUBSTR( ).

Return Value

Character. LEFT( ) returns a character string.

Example

The following example uses two different ways to display the string result from the LEFT( ) function, which returns the first four letters in the string, "Redmond, WA":

? LEFT('Redmond, WA', 4)          && Displays the string, Redm.
myString = LEFT('Redmond, WA', 4) && Stores result in myString.
? myString                        && Displays result in myString.

For more information, see ? | ?? Command.

See Also

Reference

AT( ) Function

AT_C( ) Function

ATC( ) Function

ATCC( ) Function

ATCLINE( ) Function

ATLINE( ) Function

LTRIM( ) Function

RAT( ) Function

RATLINE( ) Function

RIGHT( ) Function

RTRIM( ) Function

SUBSTR( ) Function

LEFTC( ) Function

RIGHTC( ) Function

SUBSTRC( ) Function

Other Resources

Functions