The substring function provides all the functionality to extract pieces of a string, but Left and Right make some operations easier. Left returns the leftmost characters, and Right the rightmost characters.

In particular, extracting a substring at the end of a string can be quite complicated, needing knowledge of the length of the string, for example.

If a data element Name contains “Frederick Basset”, then the function


will return “set”. This is equivalent to «substring(Name,string-length(Name)- 2,3)»


will return “Fred”.

If the number of characters requested is more than the length of the source string, then the entire source string is returned.