Date verification query

-2

I have a normal query:

select * from TABELAS 
    Where (AlvaraNumero  <>  '0') 
    and ( AlvaraValidade <> '0000-00-00' ) 
    and ( AlvaraAnexo is  NOT Null ) 
    and ( AcidenteNumero <> '0') 
    and ( AcidenteValidade  <>  '0000-00-00' ) 
    and ( AcidenteValidade <> '0000-00-00' ) 
    and ( SeguroNumero <> '0') 
    and ( SeguroValidade <> '0000-00-00') 
    and ( FinancasValidade <> '0000-00-00') 
    and ( FinancasAnexo is NOT Null) 
    and ( SocialValidade <> '0000-00-00') 
    and ( SocialAnexo is NOT Null) 
    and ( RemuneracaoValidade <> '0000-00-00' ) 
    and ( RemuneracaoAnexo is not  Null) 
    and ( InstaladorNumero  <>  '0') 
    and ( InstaladorValidade <> '0000-00-00' ) 
    and ( InstaladorAnexo is Not Null) 
    and ( MedicaValidade <> '0000-00-00') 
    and ( MedicaAnexo is Not Null) 
    order by tb_trabalhador.id asc 

How to add to all fields that have End Validity because they are dates that can not be Null or have passed the date of today? If the date has already passed, it may no longer appear in this query.

    
asked by anonymous 23.05.2014 / 10:51

1 answer

3

In the example below will only return records with date less than the current date and time.

In Oracle:

SELECT * FROM TABELA WHERE CAMPODATA IS NOT NULL AND CAMPODATA < SYSDATE

In SQL Server:

SELECT * FROM TABELA WHERE CAMPODATA IS NOT NULL AND CAMPODATA < GETDATE()

In DB2:

SELECT * FROM TABELA WHERE CAMPODATA IS NOT NULL AND CAMPODATA < (CURRENT TIMESTAMP)

In MySQL:

SELECT * FROM TABELA WHERE CAMPODATA IS NOT NULL AND CAMPODATA < NOW()
    
23.05.2014 / 12:58