Option C is the statement that returns the result 02-JAN-2020. The statement converts the string '29-10-2019' to a date using the TO_DATE function, then adds an interval of 2 months and an interval of 5 days, and subtracts an interval of 120 seconds. The resulting date is then converted to a string using the TO_CHAR function with the format model 'DD-MON-YYYY', which produces the result 02-JAN-2020.
Here is the calculation: TO_DATE('29-10-2019') = October 29, 2019 + INTERVAL '2' MONTH = December 29, 2019 + INTERVAL '5' DAY = January 3, 2020 - INTERVAL '120' SECOND = January 2, 2020
C because: when we add INTERVAL '2' MONTH + INTERVAL '5' DAY to 29-10-2019, we get 03-01-2020, as of midnight, and then we subtract - INTERVAL '120' SECOND i.e. 2 minutes, hence we get answer as '02-JAN-2020'
Correct answer should be
SELECT TO_CHAR(TO_DATE('29-OCT-2019') + INTERVAL '2' MONTH + INTERVAL '5' DAY - INTERVAL '120' SECOND, 'DD-MON-YYYY') AS "date" FROM DUAL;
THIS. It's easy to read over the minus operator.
Also the way this is written gives ORA-01843 error.
Correct syntax would be:
SELECT to_char(to_date ('29-10-2019', 'DD-MM-YYYY') + INTERVAL '2' MONTH + INTERVAL '5' DAY - INTERVAL '120' SECOND, 'DD-MM-YYYY') AS "date" FROM dual;
No error just do ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MM-YYYY';
upvoted 2 times
...
...
...
...
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
zouve
Highly Voted 1 year, 7 months agoyanoolthecool
Most Recent 7 months, 4 weeks agomkrk01
1 year, 1 month agodexdinh91
2 years agodexdinh91
2 years agoholdfaststrongly
2 years, 4 months agokakamusili
2 years, 3 months agoRik92
2 years agojr_C
1 year, 11 months ago