YYYY: Four digit representation of year
YEAR: Year spelled out
MM: Two digit value of month
MONTH: Full name of month
MON: Three letter representation of month
DY: Three letter representation of the day of the week
DAY: Full name of the day
DD: Numeric day of the month
fm: used to remove any padded blanks or leading zeros.
SELECT TO_CHAR(hire_date, 'DD-MON-YYYY') FROM EMPLOYEES;
SELECT TO_CHAR(hire_date, 'fmYYYY') FROM EMPLOYEES;
SELECT TO_CHAR(hire_date, 'MON') FROM EMPLOYEES;
SELECT TO_CHAR(hire_date, 'YYYY/MM/DD') FROM EMPLOYEES;
9: Specifies numeric position. The number of 9's determine the display width.
0: Specifies leading zeros.
$: Floating dollar sign
.: Decimal position
,: Comma position in the number
SELECT TO_CHAR(price, '$99,999') FROM SALES;
SELECT TO_CHAR(price, '99.99') FROM SALES;
SELECT TO_CHAR(price, '99,00') FROM SALES;
SELECT TO_NUMBER('1028','9999') FROM DUAL;
SELECT TO_NUMBER('12,345','99,999') FROM DUAL;
SELECT TO_DATE('01-JAN-1985','DD-MON-YYYY') FROM DUAL;
SELECT TO_DATE('01-03-85','DD-MM-RR') FROM DUAL;