Question 1
Only the row shown below is relevant: ``` EMP_ID FIRST_NAME HIRE_DATE ------ ---------- ---------- 102 Carol 2019-07-22 ``` `hire_date` is a `DATE` whose time component is midnight. What value does the following query return (shown as `YYYY-MM-DD`)? ```sql SELECT ROUND(hire_date, 'MM') AS result FROM employees WHERE emp_id = 102 ```
A. 2019-07-01
Applies TRUNC semantics to ROUND — assumes the 'MM' model always drops back to the first day of the date's own month. ROUND only does that when the day of month is 15 or earlier.
B. 2019-07-31
Treats month rounding as snapping to the nearest month boundary expressed as the last day of the month, i.e. confuses ROUND(d,'MM') with LAST_DAY(d). Oracle's date rounding always lands on the first day of a month, never the last.
C. 2019-07-22
Assumes a format model only affects the time-of-day portion, so a DATE already at midnight is returned unchanged. The format model selects the unit that is rounded, and 'MM' rounds the month, changing the date part.
D. 2019-08-01Correct answer
With the 'MM' format model the rounding pivot is the 16th day of the month: day 22 is on or after the 16th, so the value rounds up to the first day of the next month.
Explanation
ROUND on a DATE with a format model rounds the value to the unit that model names, and for 'MM' the result is always the first day of some month. The documented pivot is the sixteenth day: days 1 through 15 round back to the first of the same month, while day 16 onward rounds forward to the first of the following month. Truncating instead of rounding would always give the first of the current month, and neither operation ever produces a month-end date.