How to select the year in PLSQL?

Asked

Viewed 381 times

0

I have a chart of company employees. Must show who completed a year of work at the company.

tabela

The data type for the field Information: DATE (dd/mm/YY)

3 answers

2


To extract the year you can use:

SELECT idFuncionario, nomeFuncionario, anoAdmissao, EXTRACT (YEAR FROM anoAdmissao) AS ano FROM Tfuncionario

If you want to select who is completing a year today can use:

SELECT Tfuncionario.* WHERE Mod(Trunc(sysdate) - Tfuncionario.anoAdmissao, 365 ) = 0

2

Thus helps?

select * from tfuncionario where anoAdmissao <= '2000/01/01' and anoAdmissao >= '1999/01/01';

where '1999/01/01' the beginning of a date and '2000/01/01' the end.

  • I can automate with sydate ?

  • make one year after being added ?

  • Select all employees who complete today one year of admission ?

  • yes, yes and yes @alexjosesilva

0

can count the years, but I could not limit to one year the date to be displayed:

SELECT trunc((months_between(sysdate, to_date(f.ANOADMISSAO,'dd/mm/yy')))/12) AS idade
FROM tfuncionario f

The query will show every year.

Browser other questions tagged

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