LEN Function

Returns the length of a string.

Category: String
Returned data type: Integer

Syntax

LEN(source)

Required Argument

source

specifies a string for which the length needs to be determined; this can be specified as string constant, field name, or expression

Note: The length of an empty string (" ") is zero. If source is NULL, the function returns a NULL value.

Tip: To remove leading and trailing blanks, use the TRIM function.

Examples

Example 1

string(30) source

source = "abcdefg"

length_string = len(source) // outputs 7

 

source = " abcdefg "

length_string = len(source) // outputs 11

 

source = " " // source contains a blank

length_string = len(source) // outputs 1

Example 2

function nvlString

return string len

//!params string inval string defaultVal

 

if isnull(parameter(1)) then return parameter(2)

else return parameter(1)

end function