Skip to main content
Previous section   Next section

LEFT

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

Synopsis

LEFT(string,length)

Arguments

string An expression that resolves to a string from which the leftmost characters are returned.
length An expression that resolves to a positive integer indicating how many characters to return. If 0, a zero-length string ("") is returned. Fractional numbers are truncated to an integer. If greater than or equal to the number of characters in string, the entire string is returned. No padding is performed.

Description

The LEFT function returns the specified number of characters from the beginning (left end) of a string. If you specify a length greater than the string length, the entire string is returned. To determine the number of characters in string, use the LEN function.

The RIGHT function returns the specified number of characters from the end (right end) of a string.

Examples

The following example uses the LEFT function to return the first three characters of MyString:

MyString = "InterSystems"
PRINT LEFT(MyString,3);   ! Returns "Int"
Copy code to clipboard

See Also

Previous section KEYIN    LENNext section