result in days of comparing 2 dates

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

Poston Mon, 10 Jul 2006 6:09 pm

ola galera, td ok? Here I am in need of a ajudinmha.
And the following need to do a select between 2 dates and compare if the range is up to 120 days, if I have to represent with 0 (zero) if it is greater to represent with 6 (sesi).

I wonder if someone can help me. From already thank you!
Joao Moraes
Location: Botucatu - SP

Poston Mon, 10 Jul 2006 6:21 pm

In this case uses a case
Code: Select all
select case
         when (to_date('01/05/2006','dd/mm/rrrr') - to_date('01/01/2006','dd/mm/rrrr')) <= 120 then
           0 /* se for até 120 dias */
         else
           1 /* se for mais que 120 dias */
         end 
from dual

flow
TBou
Location: Campo Grande - MS

Thiago Bourscheidt
thiago.info@apoiorural.com.br
Analista de Sistemas


  • See also
    Replies
    Views
    Last Post


      Return to SQL

      Who is online

      Users browsing this forum: No registered users and 2 guests