Extract text from the right of a string

Priscilla T shared this question 4 years ago
Answered

Hello,


I am trying to find out on how to extract text/number from the right of a string. For example: RIGHT("3345-1200",4) returns "1200". Any assistances or help would be much appreciated!


Thanks,

Priscilla

Replies (1)

photo
1

Hi Priscilla,


There is not currently a built-in function for this, but using a FreehandSQL Calculated field would allow you to use RIGHT(ColumnName,4). The other option is to add the following custom Advanced Function to your custom-functions.xml file. This will allow you to select the column to split from and input the number of characters to split.


<!-- month function SQL Server-->

<function>

<name>Right, SQL Server</name>

<argument>

<index>1</index>

<name>Input String</name>

<datatype>text</datatype> <!-- numeric, text, datetime -->

</argument>

<argument>

<index>2</index>

<name>Length</name>

<datatype>numeric</datatype>

</argument>

<sql>

<![CDATA[

RIGHT($1,$2)

]]>

</sql>

<database>SQLServer</database>

<database>HSQL</database>

<return>text</return>

</function>


If this does not work for you or I am missing something that could better help you, please let me know.


Cheers,

Neal

photo
1

Hi Neal,


It works! Thank you so much for your help!

You can close this ticket.


Cheers,

Priscilla

photo
1

Hi Priscilla,


Glad I could help.


Cheers,

Neal

photo
Leave a Comment
 
Attach a file