FORMAT attribute

The FORMAT attribute defines the data formatting of numeric and date fields, for input and display.

Syntax

FORMAT = "format"
  1. format is a string of characters that specifies a data format.
  2. For details about possible format strings, see Formatting data.

Usage

The FORMAT attribute can be set to define input and display format for numeric and date fields.

  • For numeric fields such as MONEY and DECIMAL, the FORMAT attribute defines the formatting string with placeholders for the thousands, the decimal separator and the front or back currency symbols. The symbols for these elements can then be specified (localized) with the DBFORMAT or DBMONEY environment variables.
  • For DATE fields, when the FORMAT attribute is not used, the default format is defined by the DBDATE environment variable.
  • The FORMAT attribute does not apply to DATETIME fields.
Tip:

Consider using the FORMAT attribute only is specific cases, and keep the default formatting for most of your date and numeric form fields.

The format specification is used when converting the input buffer to the program variable, and when displaying program variable data to form fields. For example, when defining a FORMAT="yyyy-mm-dd" for a form field bound to a program variable defined as a DATE, the user can input a date as 2013-12-24, and the date value will be displayed in the same manner.

Do not mix PICTURE and FORMAT attributes in field definitions: The PICTURE attribute is used to define an input mask for character string fields, such as vehicle registration numbers, phone numbers.

If the format string is smaller than the field width, you get a compile-time warning, but the form is usable.

If necessary to satisfy the format specification, number values are rounded before they are displayed. Consider using the format specification that matches the precision and scale of the DECIMAL or MONEY variable bound to the field.

The format string can be any valid string expression using formatting characters as described in Formatting numeric values and Formatting DATE values.

Example

EDIT f003 = order.totamount, FORMAT = "---,--&.&&@";
EDIT f005 = order.thedate, FORMAT = "mm/dd/yyyy";