1Z0-071 practice question 33 of 35

Which two statements execute successfully?

Full set: 326 questions
Answer options
A: SELECT TO_ DATE('2019-DEC-25 15:30', 'YYYY-MON-DD HH24:MI', 'NLS_ DATE_ LANGUAGE =AMERICAN' ) FROM DUAL; Correct answer
B: SELECT TO_CHAR('2019-DEC-25 15:30", YY-MON-D HH24:M2', 'NLS_DATE LANGUAGE = AMERICAN') FROM DUAL;
C: SELECT TO _DATE (TO_ CHAR (‘2019-DEC-25 03:30’, ‘YYYY-MON-DD HH12:MI’)) FROM DUAL;
D: SELECT TO _ CHAR (TO_ DATE (‘2019-DEC-25 03:30’,’YYYY-MON-DD HH12:MI’)) FROM DUAL Correct answer
E: SELECT TO _ CHAR (‘2019-DEC-25 15:30’.’YYYY-MON-DD HH24:MI’) FROM DUAL
Correct Answer:
A. SELECT TO_ DATE('2019-DEC-25 15:30', 'YYYY-MON-DD HH24:MI', 'NLS_ DATE_ LANGUAGE =AMERICAN' ) FROM DUAL;; D. SELECT TO _ CHAR (TO_ DATE (‘2019-DEC-25 03:30’,’YYYY-MON-DD HH12:MI’)) FROM DUAL
Explanation

Statement A correctly uses the TODATE function. The input string '2019-DEC-25 15:30' perfectly matches the format model 'YYYY-MON-DD HH24:MI', and the NLS parameter 'NLSDATELANGUAGE=AMERICAN' ensures the month abbreviation 'DEC' is interpreted correctly. Statement D is also valid; the inner TODATE function converts the string to a DATE data type, and the outer TOCHAR function then converts this DATE value back into a string using the session's default date format (NLSDATEFORMAT).

Why Incorrect

B. The first argument to TOCHAR for date conversion must be a DATE, not a string. Also, 'M2' is not a valid format element; it should be 'MI'.
C. The inner TOCHAR function is used incorrectly. Its first argument for date formatting must be a DATE data type, not a character string.
E. The TOCHAR function is used incorrectly. Its first argument for date formatting must be a DATE data type, not a character string.

References

1. Oracle Database SQL Language Reference, 23c. "TODATE". The syntax is TODATE(char [, fmt [, 'nlsparam'] ]). Option A matches this syntax.

2. Oracle Database SQL Language Reference, 23c. "TOCHAR (datetime)". The syntax is TOCHAR(datetimeexpr [, fmt [, 'nlsparam'] ]). The first argument must be a datetime value.

3. Oracle Database SQL Language Reference, 23c. "Format Models". This section details valid format elements like YYYY, MON, HH24, and MI.

Scroll to Top