SUBSTRING() — Returns the specified portion of a string expression.
SUBSTRING( string-expression FROM position [TO length] )
SUBSTRING( string-expression, position [, length] )
The SUBSTRING() function returns a specified portion of the string expression, where position specifies the starting position of the substring (starting at position 1) and length specifies the maximum length of the substring. The length of the returned substring is the lower of the remaining characters in the string expression or the value specified by length.
For example, if the string expression is "ABCDEF" and position is specified as 3, the substring starts with the character "C". If length is also specified as 3, the return value is "CDE". If, however, the length is specified as 5, only the remaining four characters "CDEF" are returned.
If length is not specified, the remainder of the string, starting from the specified by position, is returned. For example, SUBSTRING("ABCDEF",3) and SUBSTRING("ABCDEF"3,4) return the same value.