Oracle® TimesTen In-Memory Database SQL Reference Release 11.2.1 Part Number E13070-04 |
|
|
View PDF |
The TO_CHAR function converts a DATE, TIMESTAMP or numeric input value to a VARCHAR2.
If you are using TimesTen type mode, for information on the TO_CHAR function, refer to documentation from previous releases of TimesTen.
TO_CHAR ( Expression1[, Expression2 [, Expression3]])
Parameters
TO_CHAR has the parameters:
Parameter | 'Description |
---|---|
Expression1 |
A DATE, TIMESTAMP or numeric expression. |
Expression2 |
The format string. If omitted, TimesTen uses the default date format (YYYY-MM-DD). |
Expression3 |
A CHAR or VARCHAR2 expression to specify the NLS parameter which is currently ignored. |
Description
TO_CHAR supports different datetime format models depending on the data type specified for the expression. For information on the datetime format model used for TO_CHAR of data type DATE or TIMESTAMP, see "Datetime format models". For information on the datetime format model used for TO_CHAR of data type TT_DATE or TT_TIMESTAMP, see "Format model for ROUND and TRUNC date functions".
TO_CHAR supports different number format models depending on the numeric data type specified for the expression. For information on the number format model used for TO_CHAR of data type NUMBER or ORA_FLOAT, see "Number format models". For information on the number format model used for TO_CHAR of all other numeric data types, see "Format model for ROUND and TRUNC date functions".
Examples
SELECT FIRST 5 first_name, TO_CHAR (hire_date, 'MONTH DD, YYYY'), TO_CHAR (salary, '$999999.99') FROM employees; < Steven, JUNE 17, 1987, $24000.00 > < Neena, SEPTEMBER 21, 1989, $17000.00 > < Lex, JANUARY 13, 1993, $17000.00 > < Alexander, JANUARY 03, 1990, $9000.00 > < Bruce, MAY 21, 1991, $6000.00 > 5 rows found. SELECT TO_CHAR(-0.12,'$B99.9999') FROM dual; < -$.1200 > 1 row found. SELECT TO_CHAR(-12, 'B99999PR') FROM dual; < 12 > 1 row found. SELECT TO_CHAR(-12,'FM99999') FROM dual; < -12 > 1 row found. SELECT TO_CHAR(1234.1,'9,999.999') FROM dual; < 1,234.100 > 1 row found.