Oracle Database Administration I — Question 174
st
You need to calculate the number of days from 1
January 2019 until today.
Dates are stored in the default format of DD-MON-RR.
Which two queries give the required output? (Choose two.)
Answer options
- A. SELECT TO_CHAR(SYSDATE, 'DD-MON-YYYY') ג€" '01-JAN-2019' FROM DUAL;
- B. SELECT ROUND(SYSDATE ג€" '01-JAN-2019') FROM DUAL;
- C. SELECT ROUND(SYSDATE ג€" TO_DATE('01/JANUARY/2019')) FROM DUAL;
- D. SELECT TO_DATE(SYSDATE, 'DD/MONTH/YYYY') ג€" '01/JANUARY/2019' FROM DUAL;
- E. SELECT SYSDATE ג€" TO_DATE('01-JANUARY-2019') FROM DUAL;
Correct answer: C, E
Explanation
The correct options, C and E, both correctly calculate the difference in days between SYSDATE and '01-JANUARY-2019' using the TO_DATE function, which is necessary for date arithmetic. Options A and B are incorrect because they do not properly utilize date formatting or conversion, while option D incorrectly attempts to apply TO_DATE to SYSDATE, which is already a date type.