Parameters of the SubString function

fiedleb

Member
Can someone tell me what the each of the parameters are for the SubString function? I am trying to parse a variable and return only the last 4 characters.

To be more specific:
SubString(value to be parsed, x, y) - What do the values x and y represent?
confused.gif


Thanks.

fiedleb
 
Hi Brian

X = starting position (0 for the first character)
Y = length of string to extract

eg substr('Brian',3,2) = 'an'

In your case, if you wish to find the last 4 chars you can use
substr([string],length(rtrim([string],' ')-4,4)

Hope this helps,
 
That makes sense. But can you now tell me the purpose of the rtrim call in the length function?
 
rtrim removes trailing spaces in a variable. If the variable ALPH contains the name 'Sef', it really contains 'Sef' followed by 37 spaces. length(variable) will always be 40 in this case irrespective of its content. But length(rtrim(variable)) will be 3

Hope this helps
 
Back
Top