SELECT ADD_MONTHS ( TRUNC ( TO_DATE('31-MAR-2023','DD-MON-YYYY')-1, 'MM'), -1),
TRUNC ( LAST_DAY ( ADD_MONTHS ( TO_DATE('31-MAR-2023','DD-MON-YYYY')-1, -1))),
TRUNC (TO_DATE('31-MAR-2023','DD-MON-YYYY') - 1, 'MM')
,TRUNC (LAST_DAY (TO_DATE('31-MAR-2023','DD-MON-YYYY') - 1))
FROM DUAL
SELECT
TRUNC(ADD_MONTHS('&FROM_DATE_', -1),'MM') P_START_DATE,
LAST_DAY(ADD_MONTHS('&FROM_DATE_', -1)) P_END_DATE,
TRUNC(TO_DATE(SYSDATE),'MM') C_START_DATE,
TRUNC(LAST_DAY(sysdate)) C_END_DATE
--
-- TRUNC(ADD_MONTHS(SYSDATE, -0),'MM') ,
-- LAST_DAY(ADD_MONTHS(SYSDATE,-0))
FROM DUAL
===========================
SELECT
TRUNC(ADD_MONTHS ( TRUNC ( SYSDATE-1, 'MM'), -1)) a ,
TRUNC ( LAST_DAY ( ADD_MONTHS ( SYSDATE-1, -1))) b,
TRUNC (SYSDATE - 1, 'MM') c,
TRUNC (LAST_DAY (SYSDATE - 1)) d,
TRUNC (SYSDATE - 1, 'MM') e,
TRUNC (SYSDATE - 1, 'MM')
TRUNC ( LAST_DAY ( SYSDATE - 1)) f,
TRUNC (LAST_DAY ( SYSDATE - 1))
TRUNC ( ADD_MONTHS ( (SYSDATE - 1), -1), 'MM') g ,
ADD_MONTHS ( TRUNC ( SYSDATE-1, 'MM'), -1)ggg,
TRUNC ( LAST_DAY ( ADD_MONTHS ( (SYSDATE - 1), -1))) h,
TRUNC ( LAST_DAY ( ADD_MONTHS ( SYSDATE-1, -1))) hhh
FROM DUAL
No comments:
Post a Comment