string()

Read(2066) Label: convert, format string,

Here’s how to use string() function.

string( expression {, format } :loc )

Description:

Convert the data type of an object to string type.

Syntax:

string(expression{, format}:loc)

Note:

The function converts the data type of an object to the string type and formats the string. Parameter loc defines a language, which applies to only the datetime data; use the system language if loc is absent.

 

The format string format must match the data type of the result of expression, or the result of string(expression{, format}:loc) will be incorrect.

Parameter:

expression

The constant object or the expression to be converted to a string

format

A format string used to format the result of expression

loc

Language name, which is case insensitive. The most commonly used languages are Chinese (zh) and English (en); see A.sort() to know other languages supported in esProc

Option:

@q

Enclose string expression in double quotes and ignore parameter format

@e

Escape the undisplayable character; represent the tab, carriage return, line break in string expression with the escape characters; if there are single quotes, double quotes or an escape character in the string, add an escape character before them; ignore parameter format when the option is present

@u

With @e option, if there is a character using large character set in string expression, convert the character to a Unicode one

Return value:

String type

Example:

 

A

 

1

=string(123)

123

2

=string(date("2009-02-23")," MMM dd, yyyy")

Feb 23, 2009

3

=string(3456.78,"$#,##0.00")

$3,456.78

4

=string(5/6,"0.00%")

83.33%

5

a  b

Separate a and b with tab.

6

=string@q(A5)

"a  b"; double quoted the given character string a   b, and display the escape character.

7

=string@e(A6)

\"a\tb\"; do not display the character tab after the string is escaped and add escape character to the double quotes.

8

 中国

 

9

=string@u(A8)

\u4E2D\u56FD

10

=string(date("2009-02-23")," MMM dd, yyyy":"en")

Feb 23, 2009

Related function:

float()

int()

long()

number()

decimal()