You need to calculate the number of days from 1st January 2007 till date.
Dates are stored in the default format of dd-mon-rr.
Which SQL statements would give the required output? (Choose two .)
A.
SELECT SYSDATE – ’01-JAN-2007′ FROM DUAL;
B.
SELECT SYSDATE – TO_DATE(’01/JANUARY/2007′) FROM DUAL;
C.
SELECT SYSDATE – TO_DATE(’01-JANUARY-2007′) FROM DUAL;
D.
SELECT TO_CHAR(SYSDATE, ‘DD-MON-YYYY’) – ’01-JAN-2007′ FROM DUAL;
E.
SELECT TO_DATE(SYSDATE, ‘DD/MONTH/YYYY’) – ’01/JANUARY/2007′ FROM DUAL;
why is option B correct?
i have tried in sqlplus
both B and C are are giving the diff result as ‘B – 2235.15597’, ‘C – 2235.15692’
which is correct one B or C
?
Result is different because subtraction from sysdate occurred at different time so sysdate was a little bit different.
answer to user: you converse ’01/JANUARY/2007′ to date for subtraction.
Why does A generate ORA-01722? Why is there no implicit cast happening? Is it because of ambiguity? The reight value can be date or number and the compiler refuses to do any implicit casting?
BC
how is option E incorrect?
Because you are subtracting a date with a character.