Select dates less than a given year

Asked

Viewed 127 times

0

How can I create select to show only employees of a company who have been admitted to it before a certain year ?

inserir a descrição da imagem aqui

The type anoAdmissao is date ie: dd-mm-AA

3 answers

2


SELECT * FROM Tfuncionario where EXTRACT (YEAR FROM anoAdmissao) < '2000'

The Extract function was used to select only the year of the fieldAdmission, and then compare it with the desired year.

1

plain as that:

select * from tfuncionario where anoAdmissao < to_char('2000/01/01', 'yyyy/mm/dd');

using to_char to format a mask.

where '2000/01/01' corresponds to the given period of the question

0

I got it with this piece of code:

select * 
from tfuncionario F 
where F.ANOADMISSAO <= ('01/01/00');
  • show, it is good to use to_char to guarantee values

  • This sql may give error if the "Section" parameters have been changed.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.