The document describes different format elements that can be used with the TO_CHAR, TO_NUMBER, and TO_DATE functions in Oracle SQL to format dates, numbers, and strings. It provides examples of formatting dates, numbers with thousands separators and decimal places, and converting strings to dates and numbers.
Download as TXT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
16 views
Convertion Functions
The document describes different format elements that can be used with the TO_CHAR, TO_NUMBER, and TO_DATE functions in Oracle SQL to format dates, numbers, and strings. It provides examples of formatting dates, numbers with thousands separators and decimal places, and converting strings to dates and numbers.
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1
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;