RIGHT( )
Extracts a substring from a string, starting from the rightmost, or last, character.
Syntax
RIGHT(str)
RIGHT(str, n)
Arguments
str
The string from which to extract a substring.
n
The number of characters to extract, starting from the last character.
Returns
A substring of a specific length.
If you omit n, the number of characters to extract, the function returns the last character only.
If n is zero, the function returns an empty string.
If n is greater than the length of the string, the function returns the entire string.
Example
The following example displays the last four characters of each value in the ProductCode data field:
RIGHT([ProductCode], 4)
The following example uses RIGHT( ) in conjunction with the LEN( ) and FIND( ) functions to display the characters that appear after the hyphen in a product code. This example assumes that the number of characters after the hyphen varies. Therefore, the length of the entire string (returned by LEN( )) minus the length up to the hyphen (returned by FIND( )) is the number of characters to display.
RIGHT([ProductCode], (LEN([ProductCode]) - FIND("-" , [ProductCode])))
If the product code is ModelA-Ford, RIGHT( ) returns Ford. If the product code is ModelB-Toyota, RIGHT( ) returns Toyota.