FORMAT attribute
The FORMAT
attribute defines the data formatting of numeric and date
fields, for input and display.
Syntax
FORMAT = "format"
- format is a string of characters that specifies a data format.
- For details about possible format strings, see Formatting data.
Usage
The FORMAT
attribute can be specified to define input and display format for
fields bound to numeric and date variables.
-
With fields bound to numeric variables such as
MONEY
,DECIMAL
,FLOAT
andSMALLFLOAT
, theFORMAT
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 variable. When theFORMAT
attribute is not used, the numeric format is defined globally by the DBFORMAT (or DBMONEY) environment variable. -
With fields bound to
DATE
variables, theFORMAT
attribute can be used to define the position of the year, month and day, with or without separators. When theFORMAT
attribute is not used, the date format is defined globally by the DBDATE environment variable. -
The
FORMAT
attribute does not apply to form fields that are bound to aDATETIME
orINTERVAL
variable.
Consider using the FORMAT
attribute only in specific cases, and use the DBDATE
and DBFORMAT format settings 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. Use either PICTURE
, or use
FORMAT
.
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";