Re: How do you get the year from a postgresql DATE? - Mailing list pgsql-novice

From Stephan Szabo
Subject Re: How do you get the year from a postgresql DATE?
Date
Msg-id 20091023170326.C86506@megazone.bigpanda.com
Whole thread Raw
In response to How do you get the year from a postgresql DATE?  (Mary Anderson <maryfran@demog.berkeley.edu>)
Responses Re: How do you get the year from a postgresql DATE?  ("...tharas" <tharasp@gmail.com>)
List pgsql-novice
On Fri, 23 Oct 2009, Mary Anderson wrote:

>     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;

I think you'd just want something like:
 SELECT EXTRACT(YEAR FROM fu) FROM mydate;

DATE '2000-01-01' is a syntax for providing a date literal, not treating
an expression as a date.

pgsql-novice by date:

Previous
From: Mary Anderson
Date:
Subject: How do you get the year from a postgresql DATE?
Next
From: "...tharas"
Date:
Subject: Re: How do you get the year from a postgresql DATE?