SUBSTRING
Description
SUBSTRING
is a row function that returns the specified characters of a TEXT
value based on the given start and optional end position.Syntax
SUBSTRING
(search_string
,start
,end
)Return Value
Returns one value per row of type
TEXT
.Input Parameters
- search_string
- Required. The name of a field or expression of typeTEXT(or a literal string).
- start
- Required. An integer that specifies where the returned characters start (inclusive), with 0 being the first character of the string. Ifstartis greater than the number of characters, then an empty string is returned. Ifstartis greater thanend, then an empty string is returned.
- end
- Optional. A positive integer that specifies where the returned characters end (exclusive), with theendcharacter not being part of the return value. Ifendis greater than the number of characters, or is not specified, then the whole string value (fromstart) is returned.
Examples
Return the first letter of the
name
field:SUBSTRING([name], 0, 1)
Return only the middle 3 digits with no hyphens of a US phone number in the format,
123-456-7891
:SUBSTRING([us phone number], 4, 7)