OracleDBTO_CHAR, TO_DATE, and TO_NUMBER functions. TO_CHAR can convert the datetime data type to the Data Type in the format specified by format_model.
Oracle DB TO_CHAR, TO_DATE, and TO_NUMBER functions. TO_CHAR can convert the datetime data type to the Data Type in the format specified by format_model.
The SQL statement in the example shows the last name and employment date of all employees. The employment date is displayed as "17 June 1987 ".
Example:
Modify the example in the slide so that it displays the date in the format of "Seventeenth of June 1987 12:00:00 AM.
Hr @ TEST0924> SELECT last_name, TO_CHAR (hire_date, 'fmddspth "of" Month YYYY fmHH: MI: SS am') hiredate from employees;
LAST_NAME HIREDATE
------------------------------------------------------------------------------------------------
OConnell Twenty-First of June 2007 12:00:00 AM
Grant Thirteenth of January 2008 12:00:00 AM
Whalen Seventeenth of September 2003 12:00:00 AM
Hartstein Seventeenth of February 2004 12:00:00 AM
...
107 rows selected.
Note that the month follows the specified format. In other words, the first letter and other letters are in lowercase.
For more details, please continue to read the highlights on the next page:
Related reading:
Functions, packages, and triggers in Oracle databases
Learning window functions over () in Oracle
Oracle Database random number generation function
Oracle custom functions query data dictionary items
Oracle date functions/character functions/numeric functions/conversion functions/Aggregate functions
Decode () function instructions in Oracle