nerdexam
Oracle

1Z0-007 · Question #35

Which SELECT statement should you use to extract the year from the system date and display it in the format "1998"?

The correct answer is A. SELECT TO_CHAR(SYSDATE,'yyyy'). Function TO_CHAR(x, y) converts the value x to a character or converts a date to a character string using formatting conventions. Incorrect Answers B: Function TO_DATE(x,[y]) converts the non-date value x to a date using the format specified by C: The DECODE function is used as…

Using Functions (Single-Row, Group, Conversion, Conditional)

Question

Which SELECT statement should you use to extract the year from the system date and display it in the format "1998"?

Options

  • ASELECT TO_CHAR(SYSDATE,'yyyy')
  • BSELECT TO_DATE(SYSDATE,'yyyy')
  • CSELECT DECODE(SUBSTR(SYSDATE, 8), 'YYYY')
  • DSELECT DECODE(SUBSTR(SYSDATE, 8), 'year')
  • ESELECT TO_CHAR(SUBSTR(SYSDATE, 8,2),'yyyy')

How the community answered

(21 responses)
  • A
    81% (17)
  • B
    5% (1)
  • D
    10% (2)
  • E
    5% (1)

Explanation

Function TO_CHAR(x, y) converts the value x to a character or converts a date to a character string using formatting conventions. Incorrect Answers B: Function TO_DATE(x,[y]) converts the non-date value x to a date using the format specified by C: The DECODE function is used as substitution of IF-THEN-ELSE PL/SQL construction in SQL queries. The SELECT statement provides incorrect syntax of it because it cannot have only two D: The DECODE function is used as substitution of IF-THEN-ELSE PL/SQL construction in SQL queries. The SELECT statement provides incorrect syntax of it because it cannot have only two E: This statement provide incorrect syntax of TO_CHAR() function: it requires only one parameter, not two.

Topics

#TO_CHAR#date formatting#SYSDATE#conversion functions

Community Discussion

No community discussion yet for this question.

Full 1Z0-007 Practice