QuestionQ109

VerifiedUsing Conversion Functions and Conditional Expressions

In your session, NLS_DATE_FORMAT is DD-MM-YYYY.

There are 86,400 seconds in one day.

Examine this result:

DATE -  
-----------  
02-JAN-2020  

Which statement produces this result?

Explanation

TO_DATE('29-10-2019') resolves to midnight on 29 October 2019 under the specified NLS_DATE_FORMAT. Adding INTERVAL '2' MONTH and INTERVAL '5' DAY produces midnight on 3 January 2020; subtracting 120 seconds moves the value to 23:58 on 2 January 2020. TO_CHAR(..., 'DD-MON-YYYY') displays that value as 02-JAN-2020. Oracle supports arithmetic between datetime values and interval values, and NLS_DATE_FORMAT controls the default format used for DATE values.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!