Syntax of the Format String

Applies to TestComplete 15.70, last modified on December 17, 2024

You can specify the format for column and summary values displayed in TestComplete panels and windows. You can do this in the Format page of the Format Columns dialog.

The list of the available formats depends on the type of the column selected in the Format Column dialog. The following variants are available:

Formats for Numeric Values

The format for numeric data includes the following elements (the elements in bold are obligatory, the brackets indicate optional elements):

[chars] % [width] [. prec] type [chars]
  • Chars is simply an optional fixed string to show at the beginning of the value (for instance, $). To specify the % symbol in this string, use %%.
  • Width is an optional positive integer, which defines the minimum width for the value. The value will be left-padded with blanks if it does not occupy at least this width.
  • Prec (precision), always prefixed with a period, is also an optional positive integer. The effect depends on the Type element.
  • Type is the essential element. It specifies the formatted value. Type is case-insensitive. There are two Types for integers and four Types for floats.
    • Types for integers:
      Type Description
      d decimal. The value is shown as a string of decimal digits, left-padded with 0 if the number of digits is less than Prec.
      x hexadecimal. Identical to d, except that hexadecimal digits are used.
    • Types for floats. The decimal and thousands separators are those from the current Windows settings:
      Type Description
      e scientific. Prec is the total number of digits to display, including the one before the decimal separator. Therefore, it sets the precision.
      f fixed. Fixed-decimal, Prec sets the number of digits after the decimal point, default 2.
      g general. Prec sets the total number of digits used, default 15. If the integer part of the value needs fewer digits than Prec, it is displayed as an ordinary decimal, using the number of decimals needed to fill out Prec. If it requires exactly Prec digits, then the value is displayed as an integer. If the integer part requires more digits than Prec, then the value is displayed in scientific notation. Scientific notation is also used if the value is smaller than 0.00001.
      n number. Displays the same way as f, but with thousands separators.

Following are some examples of string formatting:

Format Values
%0.2f %% 10.23%
$%8.8x $006004

Formats for Date/Time Values

The format for date/time values includes the following elements:

Element Description
AMPM The time is displayed in the 12-hour format.
d The one- or two-digit day.
dd The two-digit day. Single-digit day values are preceded by a zero.
ddd The three-character weekday abbreviation.
dddd The full weekday name.
h The one- or two-digit hour.
hh The two-digit hour. Single-digit hour values are preceded by a zero.
m The one- or two-digit minute.
mm The two-digit minute. Single-digit minute values are preceded by a zero.
ms The milliseconds.
M The one- or two-digit month number.
MM The two-digit month number. Single-digit values are preceded by a zero.
MMM The three-character month abbreviation.
MMMM The full month name.
n The one- or two-digit minute.
nn The two-digit minute. Single-digit minute values are preceded by a zero.
s The one- or two digit second.
ss The two digit second. Single-digit second values are preceded by a zero.
yy The last two digits of the year (that is, 2001 would be displayed as "01").
yyyy The full year (that is, 2001 would be displayed as "2001").
z The one-, two- or three-digit millisecond.
zzz The three-digit millisecond. Single- and two-digit millisecond values are preceded by a zero.

The format string includes the elements specified above separated by the desired symbols (:, /, spaces and so on). These symbols will be used as separators for the shown date/time values.

Below are some examples of string formats:

Format Values
h:mm:ss:ms 18:07:11:156
dddd, h:mm:ss Friday, 18:07:11

See Also

Format Columns Dialog

Highlight search results