Basic Oracle Concepts and Programming Question:
How To Convert Times to Characters in Oracle?
Answer:
You can convert dates to characters using the TO_CHAR() function as shown in the following examples:
SELECT TO_CHAR(SYSDATE, 'HH:MI:SS') FROM DUAL;
04:49:49
SELECT TO_CHAR(SYSDATE, 'HH24:MI:SS.FF') FROM DUAL;
-- Error: SYSDATE has no fractional seconds
SELECT TO_CHAR(SYSTIMESTAMP, 'HH24:MI:SS.FF9') FROM DUAL;
16:52:57.847000000
SELECT TO_CHAR(SYSDATE, 'SSSSS') FROM DUAL;
-- Seconds past midnight
69520
SELECT TO_CHAR(SYSDATE, 'HH:MI:SS') FROM DUAL;
04:49:49
SELECT TO_CHAR(SYSDATE, 'HH24:MI:SS.FF') FROM DUAL;
-- Error: SYSDATE has no fractional seconds
SELECT TO_CHAR(SYSTIMESTAMP, 'HH24:MI:SS.FF9') FROM DUAL;
16:52:57.847000000
SELECT TO_CHAR(SYSDATE, 'SSSSS') FROM DUAL;
-- Seconds past midnight
69520
Previous Question | Next Question |
How To Convert Characters to Dates in Oracle? | How To Convert Characters to Times in Oracle? |