Reference

Variant-Formats(3w)

NAME

Variant Formats

NOTES

When formatting a variant a variety of format strings may be used to generate different kinds of formatted output. A format string consists of either a named format, or a user-defined format.

The following named formats are defined:

Name Description

---- -----------

General Date Display Date, and time for non-integer values

Short Date Short date format as defined by locale settings

Medium Date Medium date format as defined by locale settings

Long Date Long date format as defined by locale settings

Short Time Short Time format as defined by locale settings

Medium Time Medium time format as defined by locale settings

Long Time Long time format as defined by locale settings

True/False Localised text of "True" or "False"

Yes/No Localised text of "Yes" or "No"

On/Off Localised text of "On" or "Off"

General Number No thousands separator. No decimal points for integers

Currency General currency format using localised characters

Fixed At least one whole and two fractional digits

Standard Same as 'Fixed', but including decimal separators

Percent Multiply by 100 and display a trailing '%' character

Scientific Display with exponent.

User-defined formats consist of a combination of tokens and literal characters. Literal characters are copied unmodified to the formatted output at the position they occupy in the format string. Any character that is not recognised as a token is treated as a literal. A literal can also be specified by preceding it with a backslash character (e.g. "t\

A user-defined format can have up to 4 sections, depending on the type of format. The following table lists sections and their meaning:

Format Type Sections Meaning

----------- -------- -------

Number 1 Use the same format for all numbers

Number 2 Use format 1 for positive and 2 for negative numbers

Number 3 Use format 1 for positive, 2 for zero, and 3

for negative numbers.

Number 4 Use format 1 for positive, 2 for zero, 3 for

negative, and 4 for null numbers.

String 1 Use the same format for all strings

String 2 Use format 2 for null and empty strings, otherwise

use format 1.

Date 1 Use the same format for all dates.

The formatting tokens fall into several categories depending on the type of formatted output. For more information on each type, see VarFormat-Dates(), VarFormat-Strings(3w) and VarFormat-Numbers(3w).

SEE ALSO

VarTokenizeFormatString(), VarFormatFromTokens(3w), VarFormat(3w), VarFormatDateTime(), VarFormatNumber(3w), VarFormatCurrency(3w).

History