SUBSTR Function



Function Type

Predefined function

Syntax

SUBSTR( <integerBegin>, <integerEnd>, <stringValue> )

Description

Returns the substring of <stringValue> as defined by the beginning and end indexes.

Argument

Description

<integerBegin>

Index to begin the substring. The <integerBegin> argument is inclusive, meaning that the character at the index specified will be the first character included in the substring.

<integerEnd>

Index to end the substring. The <integerEnd> argument is exclusive, meaning that the character at the index specified will not be included in the substring. Only characters before this index can be included.

<stringValue>

String from which to retrieve the substring.

Important

The index always starts at 0. So, the first item character in the string has an index of 0.

If a NULL is passed into any parameters in this function, it will return NULL. This behavior is consistent for all predefined functions.

If invalid parameters are passed in, the function will return an empty string. The following parameters are considered to be invalid:

  • <integerBegin> is negative
  • <integerBegin> is larger than the length of the <stringValue>
  • <integerBegin> is larger than the <integerEnd>

If <integerEnd> is larger than the length of the <stringValue>, the substring starting at <integerBegin> and extended to the end of <stringValue> will be returned.

Returns

String

Example

If a string has a value of "Discombobulated", then the function SUBSTR(6,9,"discombobulated") will return a value of "bob".

If a string has a value of "123-45-6789" and you want to return the last four characters, the function should look like this:

SUBSTR(7,11,"123-45-6789")

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*