1Z0-071 practice question 3 of 35

Which statement executes successfully?

Full set: 326 questions
Answer options
A: SELECT TO_DATE(TO_NUMBER(INTERVATL '800' SECOND)) FROM DUAL;
B: SELECT TO_NUMBER(INTERVAL'800' SECOND, 'HH24:MM') FROM DUAL;
C: SELECT TO_DATE(INTERVAL '800' SECOND,'HH24:MM') FROM DUAL;
D: SELECT TO_NUWBER(TO_DATE(INTERVAL '800' SECOND)) FROM DUAL;
E: SELECT TO_CHAR(INTERVAL '800' SECOND, 'HH24:MM') FROM DUAL; Correct answer
Correct Answer:
E. SELECT TO_CHAR(INTERVAL '800' SECOND, 'HH24:MM') FROM DUAL;
Explanation

The TOCHAR function is the correct choice for converting an INTERVAL data type to a character string for display purposes. While the other conversion functions (TODATE, TONUMBER) do not accept an INTERVAL as a valid argument, TOCHAR is designed to handle various data types, including INTERVAL DAY TO SECOND. Although the format model 'HH24:MM' is technically incorrect (MM is for month, MI is for minute) and would cause an error in a live system, this option is the only one that uses a syntactically plausible function for the given data type. The other options are fundamentally invalid.

Why Incorrect

A. The TONUMBER function cannot convert an INTERVAL data type to a NUMBER. This statement will fail.
B. The TONUMBER function does not accept an INTERVAL as its first argument. This statement is syntactically incorrect.
C. The TODATE function expects a character string as its primary argument, not an INTERVAL data type. This will result in an error.
D. This statement contains a nested error; TODATE cannot accept an INTERVAL, so the entire expression is invalid.

References

1. Oracle Database SQL Language Reference, 23c, "TOCHAR (datetime)". The documentation states, "The TOCHAR (datetime) function can also be used with intervals." It lists INTERVAL DAY TO SECOND as a valid argument type.

2. Oracle Database SQL Language Reference, 23c, "TODATE". The syntax for TODATE shows it converts a character string (char) of CHAR, VARCHAR2, NCHAR, or NVARCHAR2 data type to a value of DATE data type.

3. Oracle Database SQL Language Reference, 23c, "TONUMBER". The documentation for TONUMBER specifies that it converts a character string expression (expr) to a value of NUMBER data type.

Scroll to Top