ORACLE - Number Conversions - Number Format
Number Conversions
Element | Example | Description |
9 | 9999 | Return value with the specified number of digits with a leading space if positive. Return value with the specified number of digits with a leading minus if negative. Leading zeros are blank, except for a zero value, which returns a zero for the integer part of the fixed-point number. |
0 | 0999 9990 | Return leading zeros. Return trailing zeros. |
$ | $9999 | Return value with a leading dollar sign. |
B | B9999 | Return blanks for the integer part of a fixed-point number when the integer part is zero (regardless of "0's in the format model). |
MI | 9999MI | Return negative value with a trailing minus sign "-". Return positive value with a trailing blank. |
S | S9999 9999S | Return negative value with a leading minus sign "-". Return positive value with a leading plus sign "+". Return negative value with a trailing minus sign "-". Return positive value with a trailing plus sign "+". |
D | 99D99 | Return a decimal character (that is, a period ".") in the specified position. |
G | 9G999 | Return a group separator in the position specified. |
PR | 9999PR | Return negative value in <angle brackets>. Return positive value with a leading and trailing blank. |
L | L999 | Return the local currency symbol in the specified position. |
, (comma) | 9,999 | Return a comma in the specified position. |
. (period) | 99.99 | Return a decimal point (that is, a period ".") in the specified position. |
RN rn | RN | Return a value as Roman numerals in uppercase. Return a value as Roman numerals in lowercase. Value can be an integer between 1 and 3999. |
FM | FM90.9 | Return a value with no leading or trailing blanks. |
V | 999V99 | Return a value multiplied by 10n (and if necessary, round it up), where n is the number of 9's after the "V". |
EEEE | 9.9EEEE | Return a value using in scientific notation. |
Examples:
SELECT TO_CHAR(number, 'fmt')
FROM DUAL
EJEMPLO :
SELECT TO_CHAR(12021, '999999,99S') FROM DUAL -à RESULT '120,21+'
Results of Example Number Conversions
number | 'fmt' | Result |
-1234567890 | 9999999999S | '1234567890-' |
0 | 99.99 | ' .00' |
+0.1 | 99.99 | ' 0.10' |
-0.2 | 99.99 | ' -.20' |
0 | 90.99 | ' 0.00' |
+0.1 | 90.99 | ' 0.10' |
+1E+123 | 9.9EEEE | ' 1.0E+123' |
+123.456 | FM9.9EEEE | '1.23E+02' |
+123.45 | FM999.009 | '123.45' |
-0.2 | 90.99 | ' -0.20' |
0 | 9999 | ' 0' |
1 | 9999 | ' 1' |
0 | B9999 | ' ' |
1 | B9999 | ' 1' |
0 | B90.99 | ' ' |
+123.456 | 999.999 | ' 123.456' |
+123.45 | L999.99 | ' $123.45' |
+123.45 | FML99.99 | '$123.45' |
-123.456 | 999.999 | '-123.456' |
+123.456 | FM999.009 | '123.456' |
+123.456 | 9.9EEEE | ' 1.2E+02' |
+123.0 | FM999.009 | '123.00' |
+1234567890 | 9999999999S | '1234567890+' |
More Oracle
Mas Oracle