Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write an SQL query to calculate the number of months until Christmas. Use the MO

ID: 3937668 • Letter: W

Question

Write an SQL query to calculate the number of months until Christmas. Use the MONTHS_BETWEEN function and the DUAL table. Then, round off the answer to an integer. Decide which function - ROUND or TRANC - to be used for rounding off.

Write an SQL query to display a text string 'JANUARY 21, 2013' as a date using the TO_DATE function and the DUAL table. (Hint: correct format model to use for this string is 'MONTH DD, YYYY').

Write an SQL query to display a date '21-JAN-13' as a text string using the TO_CHAR function and the DUAL table. You may use any format model that is different from the default Oracle date format.

Explanation / Answer

select MONTHS_BETWEEN(TO_DATE(12-25-2016 00:00:00'),'MM-DD-YYYY HH24:MI:SS'),'SYSDATE) from DUAL;

select TO_CHAR('21-JAN-13','DD-MMM-YY') from DUAL;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote