Database Management
Accenture PrimermediumDatabase ManagementFunction - Scalar & Aggregate

To calculate the number of days from 1st Jan 2007 till date: Dates are stored in the default format of dd-mm-rr. Which SQL statements would give the required output?

Answer options

A
SELECT SYSDATE - TO_DATE('01/JANUARY/2007') FROM DUAL;
B
SELECT SYSDATE - '01-JAN-2007' FROM DUAL;
C
SELECT DATEDIFF(SYSDATE, '01-JAN-2007') FROM DUAL;
D
SELECT DAYS_BETWEEN(SYSDATE, TO_DATE('01-JAN-2007')) FROM DUAL;

Correct answer: SELECT SYSDATE - TO_DATE('01/JANUARY/2007') FROM DUAL;

Explanation

In Oracle, subtracting two dates gives the number of days. TO_DATE converts the string to a date.

Related Accenture Database Management questions

Practice more Accenture Database Management questions

PrimerDumps has 1400+ primer questions, 2026 mocks and coding hands-on — all free.