Oracle Database SQL — Question 164
A session's NLS_DATE_FORMAT is set to DD Mon YYYY.
Which two queries return the value 1 Jan 2019? (Choose two.)
Answer options
- A. SELECT TO_DATE('2019-01-01') FROM DUAL;
- B. SELECT DATE '2019-01-01' FROM DUAL;
- C. SELECT '2019-01-01' FROM DUAL;
- D. SELECT TO_DATE('2019-01-01', 'YYYY-MM-DD') FROM DUAL;
- E. SELECT TO_CHAR('2019-01-01') FROM DUAL;
Correct answer: B, D
Explanation
Option B correctly uses the DATE keyword to return the date in the session's specified format. Option D also correctly converts the string to a date using the TO_DATE function with the correct format mask. Options A, C, and E do not return the date in the expected format, either due to incorrect syntax or returning a string instead of a date.