SUBSTR_UDF (STRING, FLOAT, FLOAT)

Important Notice: Migration of Documentation Website

Please be advised that our documentation website is currently undergoing a migration to a new platform. To ensure you have access to the most up-to-date information, we kindly request that you visit our new documentation website located at:

Official Snowflake Snowconvert Documentation

For any immediate assistance or if you encounter any issues, please contact our support team at [email protected].

Thank you for your understanding.

Definition

Extracts a substring from a named string based on position.

PUBLIC.SUBSTR_UDF(BASE_EXPRESSION STRING, START_POSITION FLOAT, LENGTH FLOAT)

Parameters

BASE_EXPRESSION STRING

The expression from which the substring is to be extracted.

START_POSITION FLOAT

The starting position of the substring to extract from.

LENGTH FLOAT

The starting position of the substring to extract from.

Returns

The required substring.

Usage example

Input:

SELECT 
    PUBLIC.SUBSTR_UDF('ABC', -1, 1),
    PUBLIC.SUBSTR_UDF('ABC', -1, 2),
    PUBLIC.SUBSTR_UDF('ABC', -1, 3),
    PUBLIC.SUBSTR_UDF('ABC', 0, 1),
    PUBLIC.SUBSTR_UDF('ABC', 0, 2);

Output:

'','','A','','A'

Last updated