The Oracle date function ADD_MONTHS returns a date with a given number of months added that you specify.This is most powerful Oracle function for computing future months and years.
Syntax: ADD_MONTHS(datetime_expression,N)
Syntax: ADD_MONTHS(datetime_expression,N)
- It returns the date 'D' plus OR minus'N' month.
- The argument 'N' can be any positive OR negative integer.
How to Get Last Day Of Last Month
To find the last day of last month then we need to use ADD_MONTHS function
SELECT LAST_DAY(ADD_MONTHS(SYSDATE,-1)) FROM DUAL;
To find the first monday of each quarter year we need to use ADD_MONTHS
SELECT NEXT_DAY(ADD_MONTHS(TRUNC(SYSDATE, 'q'), 4), 'monday') FROM DUAL;
No comments:
Post a Comment