LOTUSSCRIPT LANGUAGE
Formats a number, a date/time, or a string according to a supplied format.
Syntax
Format[$] ( expr [ , fmt ] )
Elements
expr
Format returns a Variant containing a string, and Format$ returns a String.
If expr is a string and fmt is a numeric format string, LotusScript attempts to convert the string to a number. If successful, LotusScript then formats the result.
If the string can't be converted to a number, LotusScript attempts to interpret it as a date/time, and attempts to convert it to a numeric value. If successful, LotusScript then formats the result.
If expr can't be converted to the data type of the format string, Format returns expr without formatting it.
Formatting codes
Numeric formats
If expr is numeric, you can use one of the named numeric formats shown in the following section, or create a custom numeric format using the numeric formatting codes shown in the subsequent section.
Named numeric formats
In OS/2, the function does not append the currency symbol to the number.
The following table describes the characters you can use in fmt to create custom formats for numeric values.
x = Format$(100000,"##0,.")
If 100000 is replaced in this example by a number less than 1000 in absolute value, then this function returns "0."
The characters enclosed in quotation marks are displayed as they appear in the format string.
Since date/time values are stored as floating point numbers, date/time values can be formatted with numeric formats. They can also be formatted with date/time formats. You can either use one of the named date/time formats shown in the following section, or create a custom date/time format using the date/time formatting codes shown in the subsequent section.
Named date/time formats
The following table describes the characters you can use in fmt to create custom formats for date/time values.
To format a string using Format or Format$, use the formatting codes in the following table to create a custom string format. There are no named string formats.
Custom string formats can have one section, or two sections separated by a semicolon (;). If the format has one section, the format applies to all strings. If the format has two sections, then the first applies to nonempty strings, and the second applies to the value NULL and the empty string ("").
The following table describes the characters you can use in fmt to create a custom string format.
If the string being formatted includes a character in this position, display it. If not, display nothing. & is filled from right to left unless fmt contains an exclamation point (!).
The Format function supports additional formatting characters for dates and times in versions of LotusScript for Japan, China, the Taiwan region, and Korea.
Only single-byte characters are recognized as formatting characters. Double-byte characters are treated as literal characters. Some of the formatting characters for LotusScript in China and the Taiwan region are case-sensitive (see the following paragraphs); all of the other Asian language date/time formatting characters are case-insensitive.
When a date/time formatting code used in the Format function in LotusScript for Japan is also a date/time formatting code in WIN.INI, LotusScript for Japan interprets the code appropriately. For example, the formatting expression "Long Date" has the same meaning in LotusScript for Japan as in English-language LotusScript. (The meaning is to use the WIN.INI Long Date format.)
These formats only have meanings in Asian versions of Lotus products.
Date/time format codes
The first table shows the formatting codes for Japan.
This table shows the formatting codes for People's Republic of China.
This table shows the formatting codes for the Taiwan region.