Skip site navigation (1) Skip section navigation (2)

Re: How do you get the year from a postgresql DATE?

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Mary Anderson <maryfran(at)demog(dot)berkeley(dot)edu>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: How do you get the year from a postgresql DATE?
Date: 2009-10-24 00:06:24
Message-ID: 20091023170326.C86506@megazone.bigpanda.com (view raw or flat)
Thread:
Lists: 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.

In response to

Responses

pgsql-novice by date

Next:From: ...tharasDate: 2009-10-24 00:33:39
Subject: Re: How do you get the year from a postgresql DATE?
Previous:From: Mary AndersonDate: 2009-10-23 23:59:28
Subject: How do you get the year from a postgresql DATE?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group