TO_CHAR
The TO_CHAR
function converts a DATE
, TIMESTAMP
or numeric input value to a VARCHAR2
.
SQL syntax
TO_CHAR (Expression1
[,Expression2
[,Expression3
]])
Parameters
TO_CHAR
has the parameters:
Parameter | Description |
---|---|
|
A |
|
The format string. If omitted, TimesTen uses the default date format ( |
|
A |
Description
-
TO_CHAR
supports different datetime format models depending on the data type specified for the expression. See "Datetime Format Models" for information on the datetime format model used forTO_CHAR
of data typeDATE
orTIMESTAMP
. See "Format Model for ROUND and TRUNC Date Functions" for information on the datetime format model used forTO_CHAR
of data typeTT_DATE
orTT_TIMESTAMP
. -
TO_CHAR
supports different number format models depending on the numeric data type specified for the expression. See "Number Format Models" for information on the number format model used forTO_CHAR
of data typeNUMBER
orORA_FLOAT
. See "Format Model for ROUND and TRUNC Date Functions" for information on the number format model used forTO_CHAR
of all other numeric data types.
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.