substring({str} FROM {start} FOR {length})

Returns a substring from string str that begins with the character at the start position.

The substring function isn’t supported in Analytics Studio. An error occurs when the function is used in the UI. The function is available using the Query API. For more information, see Query CRM Analytics Data with the Query API.

start

Required. The starting position of the substring. This is the first character of the substring. The value can be positive or negative. If positive, the position is taken from the beginning of the string. If negative, the position is taken from the end of the string.

length

Optional. The length of the substring, beginning at the start position. If no value is provided, substring() extracts characters from the start position through the end of the string.

This example extracts the first three letters from each City field.

CityCityCode
AberdeenAbe
AbileneAbi
AkronAkr
AlbuquerqueAlb
AlexandriaAle