Function reference
Converts data to a string formated according to a specified format mask.
You can convert and format date, DateTime, numeric, and time data.

String ( data {, format } )

Argument Description
data The data you want returned as a string with the specified formatting. Data can have a date, DateTime, numeric, time, or string datatype.
format (optional) A string of the display masks you want to use to format the data. The masks consist of formatting information specific to the datatype of data.
If data is type string, format is required. The format string can consist of more than one mask, depending on the datatype of data.
Each mask is separated by a semicolon. See Usage for details on each datatype.

Data type: String
Returns data in the specified format if it succeeds and the empty string (‘’) if the datatype of data does not match the type of display mask specified or format is not a valid mask.

For date, DateTime, numeric, and time data, the system’s default format is used for the returned string if you do not specify a format. For numeric data, the default format is the [General] format.
For string data, a display format mask is required. (Otherwise, the function would have nothing to do.)
The format can consist of one or more masks:

Formats for date, DateTime, string, and time data can include one or two masks. The first mask is the format for the data; the second mask is the format for a null value.
Formats for numeric data can have up to four masks. A format with a single mask handles both positive and negative data. If there are additional masks, the first mask is for positive values, and the additional masks are for negative, zero, and null values.

A format can include color specifications.
If the display format does not match the datatype, the attempt to apply the mask produces unpredictable results.

Example 1
String(Date(‘2005-01-31’), ‘mmm dd, yyyy)
Returns: Jan 31, 2005

Example 2
String(DateTime(‘2005-01-31 06:08:00.63534’), ‘mmm dd, yyyy, h:m’)
Returns: Jan 31, 2005, 6:8

Example 3
String(nbr, ’0000;(000);xxxx;empty’)
0123 if nbr is 123
(123) if nbr is -123
xxxx if nbr is 0
empty if nbr is null

Example 4
String(‘ABC’, ‘@-@-@’)
Returns: A-B-C

Example 5
String(ABC, ‘@*@’)
Returns: A*B

Example 6
String(‘ABC’, ‘@@@’)
Returns: ABC

Example 7
String(‘ABC”, ‘ ‘)
Returns: a space

Example 8
Returns: 6:8

Example 9
String(Time(‘20:06:04’), ‘hh:mm:ss am/pm’)
Returns: 08:06:04 pm

Example 10
String(Time(‘08:06:04’), ‘h:mm:ss am/pm’)
Returns: 8:06:04 am:

Example 11
String(Time(‘6:11:25.300000’, ‘h:mm:ss.ffffff’)
Returns: 6:11:25.300000

Need more help with this?
Don’t hesitate to contact us here.

Thanks for your feedback.