Jump to content

Documentation/Calc Functions/RIGHT

From The Document Foundation Wiki


Function name:

RIGHT

Category:

Text

Summary:

Extracts a sub-string from the right of the supplied text string, with the length of the sub-string specified in characters.

Syntax:

RIGHT(Text[; Number])

Returns:

Returns a text string comprising the specified number of characters from the right side of the supplied text string.

Arguments:

Text is a text string (in quotation marks), a number, or a reference to a cell containing one of those types, that is the string from which characters are to be extracted.

Number is a non-negative integer, or a reference to a cell containing a non-negative integer, that is the number of characters to be extracted. If Number is omitted, RIGHT uses the value 1.

  • If Number is non-numeric, then RIGHT reports a #VALUE! error.
  • If Number is a non-integer value, then RIGHT truncates it to an integer value.
  • If Number is less than 0, then RIGHT reports an invalid argument error (Err:502).
  • If after truncation Number is equal to 0, then RIGHT returns the empty string.
  • If Text has fewer characters than the value of Number, RIGHT returns a copy of Text.

Additional details:

None.

Examples:

Formula Description Returns
=RIGHT("Input string"; 2) Here the function returns the last two characters of the supplied string. ng
=RIGHT(12,345.6789; 5) Here the function returns the last five digits of the supplied number, formatted as a text string. .6789
=RIGHT(D1; D2) where cell D1 contains the string "Input string" and cell D2 contains the number 3. Here the function returns the last three characters of the supplied string. ing
=RIGHT("Input string") Here the function returns the last character of the supplied string. The default value of 1 is applied when the Number argument is omitted. g
=RIGHT("Input string"; 0) Here the function returns the empty string.

Related LibreOffice functions:

LEFT

MID

RIGHTB

ODF standard:

Section 6.20.19, part 2

Related (or similar) Excel functions:

RIGHT