Sanscull
Sanscull

Reputation: 91

YEAR gives error

pgAdmin III always gives an error on year

ERROR: function year(date) does not exist LINE 1: SELECT YEAR(geboortedatum) as date_part .............................^^^^.........

HINT: No function matches the given name and argument types. You might need to add explicit type casts. ********** Error **********

ERROR: function year(date) does not exist SQL state: 42883
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
Character: 8

I can get the whole date that I need but I need only the year can someone help me it needs to be the youngest year from the table.

Upvotes: 3

Views: 14050

Answers (1)

VMAtm
VMAtm

Reputation: 28355

As you mentioned pgAdmin, I assume that you are using Postgres, so you need write code like this (using EXTRACT constructure):

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

Detailed documentation for the datetime functions

Upvotes: 9

Related Questions