I've tested using the answers provided here and on this thread.
The following should return the last two characters from input string.
%%=Substring("abcdefg",Length("abcdefg") - 2,2)=%%
However the minus in "-2" does not work and need to use Subtract.
Here is my final code.
SET @Name = Name
SET @NameLength = Length(@Name)
SET @EndswithS = Substring(@Name, Subtract(Length(@Name),0),1)
SET @EndS = Substring(@Name, Subtract(Length(@Name),1),1)
IF @EndswithS == 's' THEN
SET @nameend = 'Z'
ELSE SET @nameend = 'Y'
In my code the
@EndswithS selects the 1st character from end, where as
@EndS selects the 2nd character from end.