MONEY(p,s)

The MONEY data type is provided to store currency amounts with exact decimal storage.

Syntax

MONEY [ (precision[,scale]) ]
  1. precision defines the number of significant digits (limit is 32, default is 16).
  2. scale defines the number of digits to the right of the decimal point.
  3. When no scale is specified, it defaults to 2.
  4. When no (precision, scale) is specified, it defaults to MONEY(16,2).

Usage

The MONEY data type is provided to store currency amounts. Its behavior is similar to the DECIMAL data type, with some important differences:

A MONEY variable is displayed with the currency symbol defined in the DBFORMAT (or DBMONEY) environment variable.

You cannot define floating-point numbers with MONEY: If you do not specific the scale in the data type declaration, it defaults to 2. A MONEY without precision and scale defaults to MONEY(16,2), which is equivaltent to a DECIMAL(16,2).

Data type conversion can be controlled by catching the runtime exceptions. For more details, see Handling type conversion errors.

See DECIMAL(p,s) to learn other facts about the MONEY(p,s) data type.