Jump to content

Documentation/Calc Functions/LEFT

From The Document Foundation Wiki


Function name:

LEFT

Category:

Text

Summary:

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

Syntax:

LEFT(Text[; Number])

Returns:

Returns a text string comprising the specified number of characters from the left 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, LEFT uses the value 1.

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

Additional details:

None.

Examples:

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

Related LibreOffice functions:

LEFTB

MID

RIGHT

ODF standard:

Section 6.20.12, part 2

Related (or similar) Excel functions:

LEFT