Oracle Data conversion functions are common functions. The following describes the usage of the two Oracle data conversion functions for your reference.
1) TO_CHAR
This function converts the date, time, and value into text. Its main value is to provide display control over the date, time, and number. This function is very flexible and complex to use. Here we only provide examples of commonly used conversions.
1) format the date and time values
TO_CHAR date data, format encoding)
Select to_char (sysdate, 'YYYY-MM-DD HH24: MI: ss ')
From dual;
Select to_char (sysdate, 'hh24: MI: ss ')
From dual;
Select to_char (sysdate, 'yyyy') | 'Year' |
To_char (sysdate, 'mm') | 'month' |
To_char (sysdate, 'dd') | 'day' date
From dual
2) format the value
Select to_char (5764.12345, '123') from dual;
Select to_char (5764.12345, '123') from dual;
2) TO_DATE
Converts the text to the actual Oracle date/time value. Format:
TO_DATE (text, Date Format)
Select to_date ('1970-10-10 11', 'yyyy-MM-DD hh24 ')
From dual;
Insert into item_test values (
'Name-x ',
To_date ('1970-10-25 ', 'yyyy-MM-DD '));
The preceding section describes the usage of Oracle Data conversion functions.
Introduction to Oracle System Variable Functions
Syntax for creating an Oracle package
Use of Oracle to_char Functions
Implementation of oracle function return table
Learn about the Oracle FBI Index