QuestionQ120

VerifiedUsing Single-Row Functions to Customize Output

The session’s NLS_DATE_FORMAT is set to DD-MON-RR.

Which two queries display the year with four digits?

Explanation

TO_CHAR(ADD_MONTHS(SYSDATE, 6), 'dd-mon-yyyy') explicitly formats the DATE as character data using YYYY, which produces a four-digit year. A DATE returned by TO_DATE is displayed using the session default DD-MON-RR, and TO_CHAR without a format model also uses that default. TO_CHAR format models must be character expressions; therefore, the unquoted MM/DD/YYYY in choice B is not a valid format-model literal. As written, only choice E is valid and displays a four-digit year.

Learn more

Community Discussion

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