Tabular IQ
Back to Function Index

substr()

Overview

SUBSTR() returns a portion of an input string, from the start position in the string to the specified length. If a length is not specified, SUBSTR() returns all the characters from the start position to the end of the string.

Function Format

SUBSTR(string, start [, length])

Return Value

SUBSTR() returns a character string

Examples


SUBSTR("APPLES AND ORANGES", 1, 6)   = "APPLES"
SUBSTR("APPLES AND ORANGES", 8, 3)   = "AND"
SUBSTR("APPLES AND ORANGES", 12)     = "ORANGES"

Notes

  • The start position is 1-based (the first character in the string is position 1).
  • If length is omitted, all characters from start to the end of the string are returned.
  • If start is greater than the length of the string, an empty string is returned.

See Also