TO_CHAR(sysdate, 'FMMon ddth, YYYY') Result: 'Jul 9th, 2003' You will notice that in some TO_CHAR function examples, the format_mask parameter begins with "FM". This means that zeros and blanks are suppressed. This can be seen in the examples below.
Explanation: SELECT ename, hiredate, TO_CHAR((hiredate),'fmDay') "Day" FROM emp ORDER BY "Day"; In the above SQL, the fmDay format mask used in the TO_CHAR function will return the name of the Day and not the numeric value of the day.
To sort the days of the week in order, you need to return the numeric value of the day by using the fmD format mask as follows:
SELECT ename, hiredate, TO_CHAR((hiredate),'fmD') "Day" FROM emp ORDER BY "Day";
Question : What value is returned after executing the following statement? TO_TIMESTAMP('2003/12/13 10:13:18', 'YYYY/MM/DD HH:MI:SS')
string1 is the string that will be converted to a timestamp.
format_mask is optional. This is the format that will be used to convert string1 to a timestamp.
The following is a list of options for the format_mask parameter. These parameters can be used in many combinations.
Parameter Explanation YYYY 4-digit year MM Month (01-12; JAN = 01). MON Abbreviated name of month. MONTH Name of month, padded with blanks to length of 9 characters. DD Day of month (1-31). HH Hour of day (1-12). HH12 Hour of day (1-12). HH24 Hour of day (0-23). MI Minute (0-59). SS Second (0-59). Let's look at some Oracle TO_TIMESTAMP function examples and explore how to use the TO_TIMESTAMP function in Oracle/PLSQL.
For example:
TO_TIMESTAMP('2003/12/13 10:13:18', 'YYYY/MM/DD HH:MI:SS') would return '13-DEC-03 10.13.18.000000000 AM' as a timestamp value.
TO_TIMESTAMP('2003/DEC/13 10:13:18', 'YYYY/MON/DD HH:MI:SS') would also return '13-DEC-03 10.13.18.000000000 AM' as a timestamp value.