0% found this document useful (0 votes)
15 views2 pages

Char Num Date Student Notes

This document discusses Oracle SQL functions for converting between numbers, characters, and dates. It provides examples of using TO_CHAR to convert numbers to formatted character strings, TO_NUMBER to convert characters to numbers, and TO_DATE to convert characters to dates. Functions can format output or interpret nonstandard date formats.

Uploaded by

MazMoh
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views2 pages

Char Num Date Student Notes

This document discusses Oracle SQL functions for converting between numbers, characters, and dates. It provides examples of using TO_CHAR to convert numbers to formatted character strings, TO_NUMBER to convert characters to numbers, and TO_DATE to convert characters to dates. Functions can format output or interpret nonstandard date formats.

Uploaded by

MazMoh
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Character/Number/Date Conversions NUMBER VARCHAR2/CHAR DATE

FROM A NUMBER TO_CHAR TO_CHAR(38923, '$99,999.99') TO_CHAR(salary, '$99,999.99') SELECT TO_CHAR(23930, $99,999.00') FROM DUAL; SELECT TO_CHAR(salary, '$99,999.99') AS "Salary" FROM employees WHERE last_name = 'Abel'; FROM CHAR TO NUMBER TO_NUMBER converts a character string containing digits to a numeric data type, it accepts one parameter which is a column value (postal_code) or a string literal('12345') SELECT TO_NUMBER (postal_code) AS Code FROM locations; SELECT TO_NUMBER('98367') AS Code FROM DUAL; SELECT TO_CHAR(-23930, '99999PR') AS "Negative Number" FROM DUAL SELECT TO_CHAR(23930, '$99,999') AS "Currency" FROM DUAL SELECT TO_CHAR(23930, '$099,999') AS "Leading Zeros" FROM DUAL

FROM A DATE TO CHAR **consider the source..did it come from a table where the column was already configured as "date" datatype or it character data SELECT TO_CHAR(SYSDATE, 'Day, Month DDTH,YYYY ') AS "Birthday" FROM DUAL; SELECT TO_CHAR(hire_date,'Day, Month DDTH,YYYY ') AS "Birthday" FROM employees WHERE last_name = 'Abel'; SELECT TO_CHAR(TO_DATE('14-FEB-1943'),'Day Month ddTH YYYY' ) As "Valentine's Day" FROM DUAL; SELECT TO_CHAR(SYSDATE, 'fmDy DD-Mon-YYYY HH24:MI:SS AM') as "Current Time" FROM DUAL; FROM CHAR TO DATE
**WHEN DATE IS NOT IN DEFAULT FORMAT, SHOW ITS FORMAT

SELECT TO_DATE('February 20, 2003', 'Month DD, YYYY') AS "date" FROM DUAL; SELECT TO_DATE('January 1, 1900', 'Month DD, YYYY') AS "date" FROM DUAL;
**WHEN DATE IS IN DEFAULT FORMAT

SELECT TO_DATE('25-FEB-02') AS "date" FROM DUAL;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy