1) MONTHS_BETWEEN
This command accepts exactly two arguments and it is used to show the difference in months between two dates. If argument1 is greater than argument 2 then the output will be in positive integer else output will be in negative integer.
Example
SELECT MONTHS_BETWEEN(SYSDATE,'22-AUG-18') FROM DUAL;
MONTHS_BETWEEN(SYSDATE,'22-AUG-18')
-----------------------------------
5.67147289
2) ADD_MONTHS
This command accepts exactly two arguments and it is used for adding months to the current date.
Example
SELECT ADD_MONTHS(SYSDATE,12), ADD_MONTHS(SYSDATE,-12) FROM DUAL;
ADD_MONTH ADD_MONTH
--------- ---------
11-FEB-20 11-FEB-18
3) NEXT_DAY
This command accepts exactly two arguments and it is used to show on which date the next day comes.
Example
SELECT NEXT_DAY(SYSDATE,'FRIDAY') FROM DUAL;
NEXT_DAY(
---------
15-FEB-19
4) LAST_DAY
This command accepts exactly two arguments and it is used to show last day of a month.
Example
SELECT LAST_DAY(SYSDATE) FROM DUAL;
LAST_DAY(
---------
28-FEB-19
This command accepts exactly two arguments and it is used to show the difference in months between two dates. If argument1 is greater than argument 2 then the output will be in positive integer else output will be in negative integer.
Example
SELECT MONTHS_BETWEEN(SYSDATE,'22-AUG-18') FROM DUAL;
MONTHS_BETWEEN(SYSDATE,'22-AUG-18')
-----------------------------------
5.67147289
This command accepts exactly two arguments and it is used for adding months to the current date.
Example
SELECT ADD_MONTHS(SYSDATE,12), ADD_MONTHS(SYSDATE,-12) FROM DUAL;
ADD_MONTH ADD_MONTH
--------- ---------
11-FEB-20 11-FEB-18
3) NEXT_DAY
This command accepts exactly two arguments and it is used to show on which date the next day comes.
Example
SELECT NEXT_DAY(SYSDATE,'FRIDAY') FROM DUAL;
NEXT_DAY(
---------
15-FEB-19
4) LAST_DAY
This command accepts exactly two arguments and it is used to show last day of a month.
Example
SELECT LAST_DAY(SYSDATE) FROM DUAL;
LAST_DAY(
---------
28-FEB-19
No comments:
Post a Comment