exam questions

Exam 1z0-071 All Questions

View all questions & answers for the 1z0-071 exam

Exam 1z0-071 topic 1 question 23 discussion

Actual exam question from Oracle's 1z0-071
Question #: 23
Topic #: 1
[All 1z0-071 Questions]

In your session, the NLS_DATE_FORMAT is DD-MM-YYYY.
There are 86400 seconds in a day.
Examine this result:

DATE -
-----------
02-JAN-2020
Which statement returns this?

  • A. SELECT TO_CHAR(TO_DATE('29-10-2019') + INTERVAL '2' MONTH + INTERVAL '4' DAY - INTERVAL '120' SECOND, 'DD-MON-YYYY') AS "date" FROM DUAL;
  • B. SELECT TO_CHAR(TO_DATE('29-10-2019') + INTERVAL '3' MONTH + INTERVAL '7' DAY - INTERVAL '360' SECOND, 'DD-MON-YYYY') AS "date" FROM DUAL;
  • C. SELECT TO_CHAR(TO_DATE('29-10-2019') + INTERVAL '2' MONTH + INTERVAL '5' DAY - INTERVAL '120' SECOND, 'DD-MON-YYYY') AS "date" FROM DUAL;
  • D. SELECT TO_CHAR(TO_DATE('29-10-2019') + INTERVAL '2' MONTH + INTERVAL '5' DAY - INTERVAL '86410' SECOND, 'DD-MON- YYYY') AS "date" FROM DUAL;
  • E. SELECT TO_CHAR(TO_DATE('29-10-2019') + INTERVAL '2' MONTH + INTERVAL '6' DAY - INTERVAL '120' SECOND, 'DD-MON-YYYY') AS "date" FROM DUAL;
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
zouve
Highly Voted 1 year, 7 months ago
Selected Answer: C
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
upvoted 5 times
...
yanoolthecool
Most Recent 7 months, 4 weeks ago
note to self: study the calendar to know when months end, because if Dec ends on 30 instead of 31, the answer would've been A or D
upvoted 1 times
...
mkrk01
1 year, 1 month ago
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'
upvoted 3 times
...
dexdinh91
2 years ago
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;
upvoted 3 times
dexdinh91
2 years ago
NLS_DATE_FORMAT is DD-MM-YYYY
upvoted 1 times
...
...
holdfaststrongly
2 years, 4 months ago
C is correct after testing, although I don't know why it is INTERVAL '5' instead of '4'.
upvoted 2 times
kakamusili
2 years, 3 months ago
its 5 cause we are substracting the seconds from the 5th day.
upvoted 2 times
Rik92
2 years ago
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;
upvoted 1 times
jr_C
1 year, 11 months ago
No error just do ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MM-YYYY';
upvoted 2 times
...
...
...
...
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.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago