String DataWindow expression function
Description
Formats data as a string according to a specified display
format mask. You can convert and format date, DateTime, numeric,
and time data. You can also apply a display format to a string.
Syntax
|
1 |
<span>String</span> ( <span>data</span> {, <span>format</span> } ) |
|
Argument |
Description |
|---|---|
|
data |
The data you want returned as a string |
|
format (optional) |
A string of the display masks you want The format string can consist of more than one mask, depending |
Return Values
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.
Usage
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.
For information on specifying display formats,
see the Users Guide.
When you use String to format a date and the month is displayed
as text (for example, when the display format includes “mmm”),
the month is in the language of the deployment files available when
the application is run. If you have installed localized files in
the development environment or on a user’s machine, then
on that machine the month in the resulting string will be in the language
of the localized files.
For information about localized deployment
files, see the chapter on internationalizing an application in Application
Techniques.
Examples
This expression returns Jan 31, 2005:
|
1 |
<span>String</span>(2005-01-31, "mmm dd, yyyy") |
This expression returns Jan 31, 2005 6 hrs and 8
min:
|
1 |
<span>String</span>(2005-01-31 06:08:00, 'mmm dd, yyyy, h "hrs <br>and" m "min"') |
This expression:
|
1 |
<span>String</span>(nbr, "0000;(000);****;empty") |
returns:
-
0123 if nbr is
123 -
(123) if nbr is -123
-
**** if nbr is
0 -
empty if nbr is null
This expression returns A-B-C:
|
1 |
<span>String</span>("ABC", "@-@-@") |
This expression returns A*B:
|
1 |
<span>String</span>("ABC", "@*@") |
This expression returns ABC:
|
1 |
<span>String</span>("ABC", "@@@") |
This expression returns a space:
|
1 |
<span>String</span>("ABC", " ") |
This expression returns 6 hrs and 8 min:
|
1 |
<span>String</span>(06:08:02,'h "hrs and" m "min"') |
This expression returns 08:06:04 pm:
|
1 |
<span>String</span>(20:06:04, "hh:mm:ss am/pm") |
This expression returns 8:06:04 am:
|
1 |
<span>String</span>(08:06:04, "h:mm:ss am/pm") |
This expression returns 6:11:25.300000:
|
1 |
<span>String</span>(6:11:25.300000, "h:mm:ss.ffffff") |
See Also
-
String in the PowerScript
Reference