Multiple choice technology databases

Identify the correct output --- select TRUNC(TO_DATE('01-SEP-1995', 'DD-MON-YYYY'),'YEAR') from dual;

  1. 01-SEP-1995

  2. 01-JAN-1995

  3. 01-JAN-1996

  4. 1995

  5. 1996

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

TRUNC with 'YEAR' precision truncates a date to January 1st of its year. For '01-SEP-1995', this yields '01-JAN-1995' - same year, first day. The 'YEAR' format zeroes month and day to 1. TRUNC is different from ROUND which would round up to next year on certain dates.

AI explanation

TRUNC(date, 'YEAR') rounds a date down to the first day of its year, discarding the month and day components. Since 01-SEP-1995 falls within 1995, truncating to the year boundary gives 01-JAN-1995, not 01-JAN-1996 (which would be the ceiling, not the truncation) or the original date unchanged.