0

If I do the example of documenting works:

SELECT EXTRACT(YEAR FROM TIMESTAMP '2001-02-16 20:38:40');

But integrating it in my query gives an error, it will be very basic, but I do not know what it is.

select
responsable, 
fecha_contratado,
EXTRACT(YEAR FROM TIMESTAMP fecha_contratado) as alta
from rrhh.empleado
where responsable is not null

Thank you very much for the help Postgres 9.3

4
  • 1
    What is fecha_contratado column type ? Commented Apr 18, 2017 at 17:46
  • date (Example : "2016-08-04") Commented Apr 18, 2017 at 17:47
  • While I think @OtoShavadze has it solved in his answer, it would be VERY helpful to share the error you are getting in the future. Commented Apr 18, 2017 at 17:49
  • @JNevill Okay. In the next question I will. Greetings. Commented Apr 18, 2017 at 17:52

1 Answer 1

1

You don't need TIMESTAMP keyword in this case, try this:

select
responsable, 
fecha_contratado,
EXTRACT(YEAR FROM fecha_contratado) as alta
from rrhh.empleado
where responsable is not null
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.