Returns a substring of specified length from the string passed to the function, starting with the specified index. If the length is not passed then returns a string from the start position till the end of the string. The function uses zero-based indexing.
= SUBSTRING(str, startIndex)
= SUBSTRING(str, startIndex, length)
str |
A string that contains the characters which have to be extracted. . The value can be specified as a decimal value (e.g., 37.48), as a string (“Word”), as the value of a variable (e.g, FirstName) or as a date ("02/19/2009”) |
startIndex |
A positive integer which specifies the start position from which characters have to be extracted. |
Length (optional) |
A non negative integer which specifies the number of characters to be extracted. |
String
In the case of an error, the function displays an error message: “SUBSTRING(str, startIndex, length): Error message” .
The function can be used in combination with other functions.
Example |
Returns |
= SUBSTRING(“TEST”, 2) |
“ST” |
= SUBSTRING(“Iron Speed Designer”, 5, 5) |
“Speed” |
= SUBSTRING(“$1234”, 0, 1) |
“$" which is the currency sign |
= SUBSTRING(FirstName, 0, 1) |
The first character of the first name. |
= UPPER(SUBSTRING(“Iron Speed Designer”, 5, 5)) |
The upper case version of the extracted string. |
= CONCATENATE(“Iron”, SUBSTRING(“Iron Speed Designer”, 5, 5)) |
A concatenated version of the extracted string with the passed string. |