Jose
Jose

Reputation: 47

Extract year from postgres date

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

Upvotes: 0

Views: 89

Answers (1)

Oto Shavadze
Oto Shavadze

Reputation: 42753

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

Upvotes: 1

Related Questions