Multiple choice technology databases

Which SELECT statement should you use to extract the year from the system date and display it in the format "1998"? A. SELECT TO_CHAR(SYSDATE,'yyyy') FROM dual; B. SELECT TO_DATE(SYSDATE,'yyyy') FROM dual; C. SELECT DECODE(SUBSTR(SYSDATE, 8), 'YYYY') FROM dual; D. SELECT DECODE(SUBSTR(SYSDATE, 8), 'year') FROM dual; E. SELECT TO_CHAR(SUBSTR(SYSDATE, 8,2),'yyyy') FROM dual;

  1. A

  2. B

  3. C

  4. D

  5. E

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

TO_CHAR converts a date value to a string with the specified format. Option A correctly extracts the year from SYSDATE and displays it in 'yyyy' format (e.g., '1998'). TO_DATE (B) converts string to date, the opposite direction. DECODE (C, D) is for conditional logic, not date formatting. Option E incorrectly mixes SUBSTR string manipulation with TO_CHAR.