LAST( ) function

Returns a specified number of characters from the end of a string.

Syntax

LAST(string, length)

Parameters

Name Type Description
string character The field, expression, or literal value to return the characters from.
length numeric The number of characters to return.

Output

Character.

Examples

Basic examples

Returns "Savings":

LAST("Account Type: Savings", 7)

Returns "efghi":

LAST("abcdefghi", 5)

Returns "fghi ":

LAST("abcdefghi ", 5)

Returns "   abc", because the string value is shorter than the specified length of 6, so leading spaces are added to the output:

LAST("abc", 6)

Remarks

Blank results caused by trailing spaces

Trailing spaces in string can cause the results produced by the LAST( ) function to be blank.

For example, the output for LAST("6483-30384   ", 3) is "   ".

You can use the ALLTRIM( ) function in conjunction with LAST( ) to remove any trailing spaces in string.

For example, LAST(ALLTRIM("6483-30384   "), 3) returns "384".

Returning characters from the start of a string

If you want to return a specified number of characters from the start of a string, use the SUBSTR( ) function. For more information, see SUBSTR( ) function.