Help on last day of the month per year

Dúvidas, dicas e truques de SQL, Select, Update, Delete, cláusulas, operações com joins, Funções em SQLs, etc
  

Poston Thu, 23 Jul 2009 10:44 am

Hello Friends.

To killing me and would like ideas from colleagues!

I need to make a LOV with the last day of the month during a certain period, I have the select below:
Code: Select all
SELECT To_Char(last_day(Trunc(TO_DATE('01/01/2009','DD/MM/YYYY')))) ,
To_Char(last_day(Trunc(TO_DATE('01/02/2009','DD/MM/YYYY')))) ,
To_Char(last_day(Trunc(TO_DATE('01/03/2009','DD/MM/YYYY')))) ,
To_Char(last_day(Trunc(TO_DATE('01/04/2009','DD/MM/YYYY'))))
FROM DUAL
But this coming as columns would do come as lines?

like this: 1/31/2009 2/28/2209 ...

Any idea and welcome!!!

Thank you..

Douglas-Madmax.

## For a good organization, search for the codes within the CODE tag. Thanks:D ##
madmax
Location: São Paulo

Poston Thu, 23 Jul 2009 2:10 pm

I don't know if it helps, but did so.

Code: Select all
declare
   type r_meses is record (
      mês   VARCHAR2(200)
    );
   
   type t_meses is table of r_meses index by binary_integer;
   
   meses   t_meses;
begin
for i in 1..12 loop
SELECT To_Char(last_day(Trunc(TO_DATE('01/'||lPAD(i,2)||'/2009','DD/MM/YYYY')))) 
into meses(i).mês
FROM DUAL;
dbms_output.put_line(meses(i).mês);
end loop;

end;
I hope I helped.

Alex Silva ## For a good organization, search for the codes within the CODE tag. Thanks:D ##
alexrsilva
Location: Rio de Janeiro - RJ

Poston Thu, 23 Jul 2009 3:42 pm

Alrsilva, good example, but for use in a LOV, complicates things a bit.

I would do it that way, considering that it will be inserted into the query of the lov Follows example.

Code: Select all
SELECT LAST_DAY(TO_DATE('01/'||ROWNUM||'/2009','DD/MM/YYYY'))
  FROM V$SESSION --PODE SER QUALUQER TABELA AQUI COM 12 OU MAIS DE 12 REGISTROS
WHERE ROWNUM <= 12;
RodrigoValentim
Location: Salvador - BA

Rodrigo Valentim
Analista de Sistemas
Oracle Developer

Campanha: Faça uma pesquisa antes de perguntar!!!

Poston Thu, 23 Jul 2009 4:12 pm

Actually, I am now getting with Forms, as I had no idea and he posted in SQL, I answered.
It is a good tip for when you need it.

Att, Alex Silva
alexrsilva
Location: Rio de Janeiro - RJ

Poston Thu, 23 Jul 2009 5:55 pm

Ladies And Gentlemen.

I would like to thank all the alrsilva and the RodrigoValentim, the solution of Rodrigo fell like a glove.

Thanks ...:-

Douglas-Madmax
madmax
Location: São Paulo


  • See also
    Replies
    Views
    Last Post


    Return to SQL

    Who is online

    Users browsing this forum: No registered users and 5 guests