display first day of the month between two dates

SELECT   TO_CHAR (R_MONTH, 'dd/mm/yyyy') MONTH

  FROM   (  SELECT   ADD_MONTHS (TO_DATE ('12-2020', 'mm-yyyy'), ROWNUM - 1)

                        R_MONTH

              FROM   DBA_OBJECTS

             WHERE   ROWNUM <=

                        MONTHS_BETWEEN (

                           TO_DATE ('01-2021', 'mm-yyyy'),

                           ADD_MONTHS (TO_DATE ('12-2020', 'mm-yyyy'), -1)

                        )

          ORDER BY   R_MONTH);


------------------------------------------------------


insert into fiscal_M

select * from (

SELECT TO_CHAR(WHICH_MONTH, 'yyyymm') fiscal_MONTH_TXT,trunc(WHICH_MONTH) DAT,'2020' YAR,TO_CHAR(WHICH_MONTH, 'Mon-yyyy') YAR_MM

FROM

(

SELECT

ADD_MONTHS(TO_DATE('07-2021','mm-yyyy'), ROWNUM-1) WHICH_MONTH

FROM

DBA_OBJECTS

WHERE

ROWNUM <= MONTHS_BETWEEN(TO_DATE('06-2022','mm-yyyy'), ADD_MONTHS(TO_DATE('07-2021','mm-yyyy'), -1))

ORDER BY

WHICH_MONTH

))

Comments

Popular posts from this blog

Formula list

Formula Line change query