Mega Code Archive

 
Categories / Oracle PLSQL Tutorial / SQL Data Types
 

TO_CHAR(SYSDATE, MONTH DD, YYYY, HH24

The following example gets the current date and time from the database using the SYSDATE function. Converts it to a string using TO_CHAR() with the format MONTH DD, YYYY, HH24:MI:SS. The time portion of this format indicates that the hours are in 24-hour format. SQL> SQL> SELECT TO_CHAR(SYSDATE, 'MONTH DD, YYYY, HH24:MI:SS')   2  FROM dual; TO_CHAR(SYSDATE,'MONTHDD,YYY ---------------------------- MAY       30, 2007, 21:29:42 SQL>