# SubString

{% hint style="info" %}
The **`Substring()`** function returns a subset of a <mark style="color:blue;">text</mark>.&#x20;

This function is NOT SQL compatible. For more information about SQL compatibility, see our [documentation](https://docs.wem.io/platform/~/changes/y5gAfiyi2fILzrLzUUHj/wemreference/sql-compatibility).
{% endhint %}

{% hint style="success" %}
Returns a new <mark style="color:green;">text</mark> that is a subset of <mark style="color:blue;">`text`</mark> beginning at a position through a number of characters. \
Returns <mark style="color:red;">`Invalid expression`</mark> if one of the parameters is not valid.&#x20;
{% endhint %}

### Syntax

<details>

<summary><code>Substring(</code><mark style="color:blue;"><code>text</code></mark><code>,</code><mark style="color:blue;"><code>length</code></mark><code>)</code></summary>

`Substring("Important", 6)`\
\=> *"Import"*

</details>

<details>

<summary><code>Substring(</code><mark style="color:blue;"><code>text</code></mark><code>,</code><mark style="color:blue;"><code>start_position</code></mark><code>,</code><mark style="color:blue;"><code>length</code></mark><code>)</code></summary>

`Substring("Important", 2, 4)`\
\=> *"port"*

</details>

### Parameters

<table><thead><tr><th width="202.70825474075613">Name</th><th width="150">Type</th><th width="150" align="center">Required</th><th width="248.15953250810662">Description</th><th data-hidden>Required?</th></tr></thead><tbody><tr><td><mark style="color:blue;"><code>text</code></mark></td><td>text</td><td align="center"><span data-gb-custom-inline data-tag="emoji" data-code="2611">☑️</span></td><td>a text</td><td>yes</td></tr><tr><td><mark style="color:blue;"><code>start_position</code></mark></td><td>numeric</td><td align="center"></td><td>(<em>optional</em>) the position to start from</td><td></td></tr><tr><td><mark style="color:blue;"><code>length</code></mark></td><td>numeric</td><td align="center"><span data-gb-custom-inline data-tag="emoji" data-code="2611">☑️</span></td><td>the number of characters to take from <code>text</code></td><td></td></tr></tbody></table>
