Navigation:  »No topics above this level«


Advantage Concepts

Return to chapter overview

Scalar function that converts a numeric expression to a character string.

Supported in SQL:

Yes (the 3 parameter version is supported in SQL)

Supported in Navigational:



STR(<nNumber>, [<nLength>], [<nDecimals>]) à cNumber



The numeric expression to be converted to a character string.


The length of the character string to return, including decimal digits, decimal point, and sign.


The number of decimal places to return.

Return Values

STR() returns <nNumber> formatted as a character string. If the optional length and decimal arguments are not specified, STR() returns the character string according to the following rules:

Results of STR() when optional nLength and nDecimals arguments are not specified:


Return Value Length

Field Variable

Field length plus decimals (Note: This is Clipper-compatible, but differs from the FoxPro standard. FoxPro defaults to a length of 10 for fields if the nLength value is not specified)


Minimum of 10 digits plus decimals


Minimum of 3 digits


3 digits


5 digits


7 digits


STR() is a numeric conversion function that converts numeric values to character strings. It is commonly used to concatenate numeric values to character strings. STR() has applications displaying numbers, creating codes such as part numbers from numeric values, and creating index keys that combine numeric and character data.

The inverse of STR() is VAL(), which converts character numbers to numerics.

Note If <nLength> is less than the number of whole number digits in <nNumber>, STR() returns asterisks instead of the number.


Note If <nLength> is less than the number of decimal digits required for the decimal portion of the returned string, the number is rounded to the available number of decimal places.


Note If <nLength> is specified but <nDecimals> is omitted (no decimal places), the return value is rounded to an integer.

See Also