- DATE data type stores info about century,year,month,day,hour,minute and second for each date value.
- TO MANIPULATE AND EXTRACT VALUES from date column of a table,oracle provides some date functions.
ADD_MONTHS
Returns date after adding the number of months.
SELECT ADD_MONTHS(sysdate,4) FROM dual;
LAST_DAY(d)
Returns the last date of the month.
SELECT SYSDATE,LAST_DAY(sysdate)"Last" FROM DUAL;
MONTHS_BETWEEN(d1,d2)
Returns number of months between d1 and d2.
SELECT MONTHS_BETWEEN('02-feb-92','02-dec-91') FROM DUAL;
Query : select all the orders in ascending order of month.
SELECT * from Orders ORDER BY to_char(odate,'MM');