---
schema_version: "1"
id: 938e1c4a0c64a3a484e7b8b2484a3af4d79a5974d98ef93103805ca2d95f376e
title: Substring()
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/marketing-cloud/ampscript/references/string/mc-ampscript-reference-string-substring.md
canonical_url: https://developer.salesforce.com/docs/marketing/marketing-cloud-ampscript/references/mc-ampscript-string/mc-ampscript-reference-string-substring.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 79cd2caea3ec0422a4f5c26296cc61053c7a94dc7682b4c3bd0ee7b0a42c14e8
products:
  - AMPscript for Marketing Cloud
  - Marketing Cloud
---
# Substring()

Returns a portion of a string, beginning at a specified character position. You can optionally specify the length of the substring to return.

## Availability

<table>
  <tr>
    <td>Marketing Cloud Engagement</td>
    <td>✅ Yes</td>
  </tr>
  <tr>
    <td>Marketing Cloud Next</td>
    <td>✅ Yes</td>
  </tr>
</table>

This function became available in Marketing Cloud Next during the Summer ’26 release (API version 67.0).

## Syntax

```
Substring(sourceString,
          startPosition,
          substringLength)
```

The `Substring()` function has three parameters:

- `sourceString` (string): Required. The string that contains the substring you want to identify.
- `startPosition` (number): Required. The character position to begin the substring. If the specified character position exceeds the length of `sourceString`, the function returns an empty string.
- `substringLength` (number): The number of characters to return after the initial character. If you don’t specify a length, the substring continues to the end of the string.

## Usage

This example uses the `Substring()` function to remove part of a string of text and return the result.

```
%%[
  Var @rewardsSegment, @rewardsTier
  Set @rewardsSegment = "0312F-Gold"
  Set @rewardsTier = Substring(@rewardsSegment, 7)
]%%
<p>Thank you for being a %%=v(@rewardsTier)=%% rewards member!</p>
```

The example returns the specified substring.

```
Thank you for being a Gold rewards member!
```
