---
schema_version: "1"
id: f70cc016acd28eea5c64afc6a1663196d67dc263336344c398dc14f6533dbcd0
title: SUBSTRING
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/data-cloud/data-cloud-query-guide/references/data-cloud-sql-reference/scalar-func/string-func/substring.md
canonical_url: https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/substring.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 1cdb09d75fcb2af0ba0a938adceff95983649b7065b069980afea29b04441567
products:
  - Data 360 Query Guide
  - Data 360 Developer Documentation
---
# `SUBSTRING`

**Applies to:** ✅ Data 360 SQL ✅ Tableau Hyper API

Extracts a substring from a string starting at a specified position.

## Syntax

```sql
substring(<string> from <start> for <count>)
```

## Arguments

### Required

- `<string>`: The source string.
- `<start>`: The starting position (1-based).
- `<count>`: The number of characters to extract.

## Returns

Returns a text value containing the extracted substring.

## Considerations

- Position indexing is 1-based.
- If `<start>` plus `<count>` exceeds the string length, the function returns characters to the end of string.
- Same as `substr(string from start for count)`.

## Examples

### Extract Substring

Extract characters from a string.

```sql
SELECT substring('Thomas' from 2 for 3) AS result;
```

Returns `'hom'`, extracting 3 characters starting at position 2.

## Related Documentation

- [String Types](https://developer.salesforce.com/docs/data/data-cloud-query-guide/datatype/string.md)
