In Oracle, the "to_char()" function is used to convert dates into character types in a certain format. It is often used in conjunction with select statements. The syntax is "select to_char(date,"conversion format") time from dual;".
The operating environment of this tutorial: Windows 10 system, Oracle 11g version, Dell G3 computer.
The two conversion functions that are most closely related to date operations in daily work: to_date(), to_char()
many A date format:
YYYY: the year represented by four digits
YYY, YY, Y: the last three, two or two digits of the year One digit, the default is the current century
MM: Month number from 01 to 12
MONTH: Nine-character month, right Fill in with spaces
MON: three-character month abbreviation
1.to_date(): It converts character type into date type according to a certain format
Specific usage: to_date(''2004-11-27 '',''yyyy-mm-dd''), the former is a string, and the latter is a converted date formatNote that the two before and after must correspond to one. For example: to_date(''2004-11-27 13:34:43'', ''yyyy-mm-dd hh24:mi:ss'') will get the specific timeSQL>select to_date('2003-10-17 21:15:37','yyyy-mm-dd hh24:mi:ss') from dual2.to_char(): The date is converted into a character type according to a certain format
SQL> select to_char(sysdate,''yyyy-mm-dd hh24:mi:ss'') time from dual;TIME ------------------- 2004-10-08 15:22:58That is, convert the current time into character type according to yyyy-mm-dd hh24:mi:ss format Recommended tutorial: "
Oracle Video Tutorial"
The above is the detailed content of What is the usage of to char conversion in oracle. For more information, please follow other related articles on the PHP Chinese website!