SUBSTRING

Applies to: ✅ Data 360 SQL ✅ Tableau Hyper API

Extracts a substring from a string starting at a specified position.

Syntax 

1substring(<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.

1SELECT substring('Thomas' from 2 for 3) AS result;

Returns 'hom', extracting 3 characters starting at position 2.

Related Documentation 

DID THIS ARTICLE SOLVE YOUR ISSUE?
Let us know so we can improve!