6 Replies Latest reply: May 15, 2017 10:45 AM by MARIO SOARES RSS

    Como criar calendario com mes customizado

    Antonio Mercadante

      Caros, Bom dia!

       

      Preciso criar um calendário em que os meses se iniciem em 16 e finalizem em 15 Ex;

      Quando eu selecionar mês de abril ele exiba as datas de 16/04 a 15/05.

       

      Alguém sabe como faze isso?

       

      Utilizo o código abaixo para criar o calendario

       

      SUB CriarCalendario(nomeTabela, sufixoCampos, DataInicio, DataFim)

              [$(nomeTabela)]:                                                                      

             LOAD

            

             [Data]                                         AS [Data$(sufixoCampos)]

                      ,      Day([Data])                                     AS [Dia$(sufixoCampos)]

                   ,      Week([Data])                                   AS [Semana$(sufixoCampos)]

                      ,      Month([Data])                                   AS [Mês$(sufixoCampos)]

                   ,      Ceil(Month([Data]) / 3) & '° Trim'       AS [Trimestre$(sufixoCampos)]

                      ,      Year([Data])                                   AS [Ano$(sufixoCampos)]

                      ,  Date(MonthStart([Data]),'MMM/YYYY') AS [MêsAno$(sufixoCampos)]

                  

                   ,      1 + Ceil(([Data] - Floor(WeekEnd(MonthStart([Data]), 0, -1))) / 7) & 'ª sem'

                                                                                       AS [Semana do Mês$(sufixoCampos)]

                   ,      If([Data] = AddMonths(MonthStart(Data), 1) - 1, 1, 0)

                                                                                       AS [É Último Dia Mês$(sufixoCampos)]

                                                                                     

                   ,      MonthStart(AddMonths([Data], 1)) - MonthStart([Data])

                                                                                       AS [Quantidade Dias Mês$(sufixoCampos)];                                                                                                                                                                                                                                                                                                                                                                                                            

             LOAD

                           Date(Date($(vDataIni), 'DD/MM/YYYY') -1 + RecNo(),'DD/MM/YYYY')                   AS [Data]

              AUTOGENERATE

                           Date($(vDataFim), 'DD/MM/YYYY') - Date($(vDataIni), 'DD/MM/YYYY')+1;

                                                                                      

      ENDSUB;

       

       

      chamada da sub

       

      [Calendario Auxiliar]:

      load

      min(Data) as [Data Inicio],

      max(Data) as [Data Fim]

      //NUM(TODAY()) as [Data Fim]

      //Resident [CHAVE VENDA/ATIVACAO];

      Resident [APONTAMENTOS];

      let vDataIni = Peek('Data Inicio');

      let vDataFim = peek('Data Fim');

       

       

      drop tables [Calendario Auxiliar];

       

       

      call CriarCalendario('CALENDARIO','',$(vDataIni),$(vDataFim));