How do you get the year from a postgresql DATE?

Поиск
Список
Период
Сортировка
От Mary Anderson
Тема How do you get the year from a postgresql DATE?
Дата
Msg-id 4AE24360.5080508@demog.berkeley.edu
обсуждение исходный текст
Ответы Re: How do you get the year from a postgresql DATE?  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
Список pgsql-novice
Hi guys,

    Honest, I am not really a newbie, but I don't see any postgresql
function to do this in the documentation.  I want to do something like

CREATE TABLE mydate(fu DATE);
INSERT INTO mydate VALUES ('2000-01-01');
SELECT EXTRACT(YEAR FROM DATE fu) FROM mydate;

and get 2000.

But I get a syntax error for the EXTRACT statement when I do this.

SELECT EXTRACT(YEAR FROM DATE '2000-01-01') works just fine.  But how do
I get a postgres DATE from a column in a table into EXTRACT as the last
argument?


This can't be all that hard!

Mary

В списке pgsql-novice по дате отправления:

Предыдущее
От: richard terry
Дата:
Сообщение: Re: creating view - conditional testing in construct
Следующее
От: Stephan Szabo
Дата:
Сообщение: Re: How do you get the year from a postgresql DATE?