3
votes

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.

1
is this MSSQL (T-SQL), MySQL, Oracle ...?DLeh
pgAdmin is probably PostgreSQL ?Darius X.
@DLeh It is most likely Postgresql since OP uses pgAdmin.Magnilex
In the time it took you to write this question I bet you could've found the answerMackan

1 Answers

5
votes

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