String Scalar Functions

Table 130. String Scalar Functions 

Function

Description

Ascii (s)

Returns an ASCII code of the first symbol in the string. s.

Example:

Ascii ("AZ") = 65

Concat (s1, s2)

Returns text strings s1 and s2 concatenated.

Example:

Concat ("interactive","reporting") = interactivereporting

Initcap (s)

Returns string s with the first letter of each word capitalized, and remaining characters in lower case.

Example:

Initcap ("santa fe") = Santa Fe

Instr (s1,s2,n,m)

Returns position of mth occurrence of string s2 in string s1, beginning at position number n. If n is negative, the count is made backwards from the end of s1. If no values are found, 0 is returned.

Examples:

Instr ("Mississippi",'s',5,2) = 7

Instr ( City, 'a', -2, 1 )

Length (s)

Returns character count of string s.

Example:

Length ("Pittsburgh") = 10

Lower (s)

Returns string s in lower case.

Example:

Lower ("CD-Rom") = cd-rom

Ltrim (s1,s2)

Trims string s1 from the left, up to the first character not included in string s2.

Example:

Ltrim ("Mr. Jones", "Mr. ") = Jones

Replace (s1,s2,s3)

Returns string item s1 with all occurrences of string s2 replaced by string s3. The default for s3 deletes each occurrence of s2.

Example:

Replace (customer,"Mrs.","Ms.") = replaces Mrs. with Ms. for all values of customer containing ‘Mrs.

Rtrim (s1,s2)

Trims column string s1 from the right, up to the first character not included in string s2.

Example:

Rtrim ("Columbus, OH",", OH") = Columbus

Substr (s,n,m)

Returns a portion of string s, m characters long, beginning at numeric position n. The default action for m includes all remaining characters.

Example:

Substr ("312/989-9989","1","3") = "312"

Translate (s1,s2,s3)

Returns string s1, with each character contained in string s2 replaced by the corresponding characters in string s3.

Example:

Translate ("12/5/97 3:48:22",”/:”,”-|”) = 12-5-97 3|48|22

Upper (s)

Returns string s in upper case.

Example:

Example: Upper ("st.") = ST.