How to: |
The SUBSTR function extracts a substring based on where it begins and its length in the source string.
SUBSTR(length, source_string, start, end, sublength, output)
where:
Integer
Is the number of characters in source_string.
Alphanumeric
Is the string from which to extract a substring .
Integer
Is the starting position of the substring in the source string. If start is less than one or greater than length, the function returns spaces.
Integer
Is the ending position of the substring. If this argument is less than start or greater than length, the function returns spaces.
Integer
Is the number of characters in the substring (normally end - start + 1). If sublength is longer than end - start +1, the substring is padded with trailing spaces. If it is shorter, the substring is truncated. This value should be the declared length of output. Only sublength characters will be processed.
Alphanumeric
SUBSTR extracts the first three characters from LAST_NAME, and stores the results in a column with the format A3:
SUBSTR(15, LAST_NAME, 1, 3, 3, 'A3')
For BANNING, the result is BAN.
For MCKNIGHT, the result is MCK.
iWay Software |