1Z0-082 practice question 22 of 25
You need to calculate the number of days from 1st January 2019 until today. Dates are stored in the default format of DD-MON-RR. Which two queries give the required output? (Choose two.)
Full set: 142 questionsDate arithmetic in Oracle is performed by subtracting one DATE value from another, which results in the number of days between them. SYSDATE returns the current date and time.
Option B correctly calculates the difference. It relies on Oracle's implicit conversion of the string '01-JAN-2019' to a DATE, which succeeds as the format is compatible with the default DD-MON-RR. ROUND returns an integer value.
Option E uses the correct SYSDATE - TODATE(...) structure. However, the string '01-JANUARY-2019' uses the full month name, which does not match the default DD-MON-RR format model. This option is considered correct assuming a common exam question typo where 'JAN' was intended.
A. This query attempts to perform subtraction on two character strings, which will result in an ORA-01722: invalid number error.
C. The TODATE function will fail because the format of the string '01/JANUARY/2019' does not match the default NLSDATEFORMAT of DD-MON-RR.
D. The first argument to the TODATE function must be a character string, but SYSDATE is already a DATE data type, causing a syntax error.
1. Oracle Database SQL Language Reference, 19c. "Datetime Functions". SYSDATE returns a DATE value.
2. Oracle Database SQL Language Reference, 19c. "Literals". Section on "Datetime and Interval Literals" discusses date arithmetic.
3. Oracle Database SQL Language Reference, 19c. "Conversion Functions". TODATE(char [, fmt [, 'nlsparam'] ]) specifies that if fmt is omitted, the default date format is used.
4. Oracle Database Globalization Support Guide, 19c. Chapter 4, "Supporting Multilingual Databases with Unicode". Discusses the NLSDATEFORMAT parameter.
Keep practicing
Take the free 1Z0-082 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other 1Z0-082 practice questions
- Question 1Which three statements are true about using SQL*Plus?
- Question 2Which three statements are true about advanced connection options supported by Oracle Net…
- Question 3Which statement is true about the INTERSECT operator used in compound queries?
- Question 5Which two statements are true about the ORDER BY clause when used with a SQL statement co…
- Question 6Which three statements are true about the tools used to configure Oracle Net Services? (C…
- Question 7In your data center, Oracle Managed Files (OMF) is used for all databases. All tablespace…
