Skip to main content

Printing format functions

Function name

Feature

FORMAT / FORMAT2

Edits and prints data in the format you specified.

FORMAT / FORMAT2

Feature

Edit and prints data in the format you specified.

Format

FORMAT(numeric_value_or_numeric_field_name,format_string)

FORMAT2(character_field_name_or_numeric_field_name,format_string)

Settings

  1. In "numeric_value_or_numeric_field_name" ("character_field_name_or_numeric_field_name" in FORMAT2), specify the name of the field that contains the data to edit.

  2. In "format_string", specify the edit method.

Example 1. Difference between the FORMAT function and the FORMAT2 function

The printing result of the FORMAT and FORMAT2 printing format functions differs according to the edit-formula settings.

  • When you are creating with the FORMAT function

    Data

    FORMAT settings

    ZZZZZZ

    ZZZZZ9

    999999

    100

    100

    100

    000100

    0

    0

    000000

    NULL

    0

    000000

    Z: Enables zero-suppress (replaces invalid number data with a space)

    9: Disables zero-suppress (replaces invalid number data with zero)

    The FORMAT function cannot distinguish between 0 and Null. Therefore, even when Null has passed, 0 will be printed.

  • When creating with the FORMAT2 function (set as text-type)

    Data

    FORMAT2 settings

    ZZZZZZ

    ZZZZZ9

    999999

    100

    100

    100

    000100

    0

    0

    000000

    NULL

    The FORMAT2 function can distinguish between 0 and Null.

    Therefore, even when you specify "ZZZZZ9", "" (empty string) will be printed if Null has been passed to a text field.

    If Null has been passed to a numeric field, 0 will be printed.



Edit method

"nZZZ,ZZZ,ZZ9.99m"

  • n (leading character)

    ▲: Displays "▲" for minus ( - ) data.

    △: Displays "△" for minus ( - ) data.

    yen.png (Displayed for "Japanese", "Simplified Chinese", and "Traditional Chinese")

    euro.png (Displayed for "English", "French", and "Czech")

    won.png (Displayed for "Korean")

    baht.png (Displayed for "Thai")

    $

    Any other characters

  • Edit character

    Z: Enables zero-suppress

    9: Disables zero-suppress

    ,: Insert a comma (comma edit) (No break space is inserted for "French" and "Czech")

    .: Decimal point position (decimal point is printed) (Comma is inserted for "French" and "Czech")

    v: Virtual decimal point position (do not print decimal point)

  • m (suffix character)

    %

    Any other characters ($, etc.)

Reference

  • Numeric data is printed in the right of the leading character. With the default setting of the FORMAT2 function, the position of the minus sign (▲, △) is fixed and only the actual data is right-aligned.

    • FORMAT function: " ▲1"

    • FORMAT2 function: "▲ 1"

  • To add optional characters, all characters including numeric data must be within the printable number of digits for the field. Any part exceeding the printable number of digits will not appear.

Usage examples

  • Example 1: To output the numeric-type field "I2" in which the numeric data -123.456 was entered using ▲ as the prefix

    • FORMAT

      • Edit-formula: FORMAT(I2,"▲ZZ,ZZ9.99")

      • Printing result: "XX▲123.45" (X=half-width space)

    • FORMAT2

      • Edit-formula: FORMAT2(I2,"▲ZZ,ZZ9.99")

      • Printing result: "▲XX123.45" (X=half-width space)

  • Example 2: To edit and output the value of the text-type field "S1" in which no value was input

    • FORMAT

      • Edit-formula: FORMAT(S1,"ZZ,ZZ9.99")

      • Field buffer: ""

      • Printing result: "XXXXX0.00" (X=half-width space)

    • FORMAT2

      • Edit-formula: FORMAT2(S1,"ZZ,ZZ9.99")

      • Field buffer: ""

      • Printing result: ""

Reference

In Example 2, as the output destination is a text field, "" (empty string) will be stored in the value of the field buffer as the default value. When you select the FORMAT function, 0 will appear according to the format. When the FORMAT2 function is used, the displayed value will remain as "".

  • Example 3: When Null is passed to the numeric field "I1," and you are printing the value using a custom format.

    • FORMAT

      • Edit-formula: FORMAT(I1,"ZZ,ZZ9.99")

      • Field buffer: 0

      • Printing result: "XXXXX0.00" (X=half-width space)

    • FORMAT2

      • Edit-formula: FORMAT2(I1,"ZZ,ZZ9.99")

      • Field buffer: 0

      • Printing result: "XXXXX0.00" (X=half-width space)

Reference

In example 3, as the output destination is a numeric field, 0 (zero) will be stored in the value of the field buffer as the default value. When you select the FORMAT function, 0 will appear according to the format. Even when you select the FORMAT2 function, 0 will be displayed, in accordance with the format.