---
schema_version: "1"
id: 6b2a9b1a1761ce04811be0d2f096bc9a53a23bc8a5400fc9bbbd9818fc34d317
title: SUBSTR
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/substr.md
canonical_url: https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/substr.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 0ad42e4fa96e1d05dda341f9a5c8c2a91341f56662fdb5be90629b58f4d1c8a3
products:
  - Data 360 Query Guide
  - Data 360 Developer Documentation
---
# `SUBSTR`

**Applies to:** ✅ Data 360 SQL ✅ Tableau Hyper API

Extracts a substring from a string.

## Syntax

```sql
substr(<string>, <start> [, count])
```

## Arguments

### Required

- `<string>`: The source string.
- `<start>`: The starting position (1-based).

### Optional

- `count`: The number of characters to extract.

## Returns

Returns a text value containing the extracted substring.

## Considerations

- Same as `substring(string from start for count)` but with comma-separated arguments.
- Position indexing is 1-based.

## Examples

### Extract Substring

Extract two characters starting at position three.

```sql
SELECT substr('alphabet', 3, 2) AS result;
```

Returns `'ph'`.

## Related Documentation

- [String Types](https://developer.salesforce.com/docs/data/data-cloud-query-guide/datatype/string.md)
