Write an SQL query to calculate the number of months until C
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.
Solution
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;
