Requirement:- To find last day of the previous month and First day of the previous Month.
Solution:
1) This can be achieved using TRUNC function as below.
SELECT TRUNC(TRUNC(SYSDATE, 'MM') - 1, 'MM') "FIRST DAY OF PREVIOUS MONTH",
TRUNC(SYSDATE, 'MM') - 1 "LAST DAY OF PREVIOUS MONTH" , TRUNC(SYSDATE) "Today Date" FROM DUAL
2) Can be achieved using "ADD_MONTHS and LAST_DAY" function as below.
SQL>SELECT TRUNC(LAST_DAY(ADD_MONTHS(sysdate,-1))) from dual
Solution:
1) This can be achieved using TRUNC function as below.
SELECT TRUNC(TRUNC(SYSDATE, 'MM') - 1, 'MM') "FIRST DAY OF PREVIOUS MONTH",
TRUNC(SYSDATE, 'MM') - 1 "LAST DAY OF PREVIOUS MONTH" , TRUNC(SYSDATE) "Today Date" FROM DUAL
2) Can be achieved using "ADD_MONTHS and LAST_DAY" function as below.
SQL>SELECT TRUNC(LAST_DAY(ADD_MONTHS(sysdate,-1))) from dual