QuestionQ144

VerifiedUsing Single-Row Functions to Customize Output

Consider the following query:

SELECT SUBSTR(SYSDATE, 1, 5) "Result" FROM DUAL;  

Which statement is correct?

Explanation

Oracle implicitly converts SYSDATE, which is a DATE, to a character value when it is passed to SUBSTR. The resulting text uses the session’s date-format settings, so the statement executes successfully, although explicit TO_CHAR formatting is preferable when deterministic output is required.

Community Discussion

No comments yet. Be the first to start the discussion!