Re: query by partial timestamp

From: Raymond O'Donnell <rod(at)iol(dot)ie>
To: Kirk Wythers <kwythers(at)umn(dot)edu>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: query by partial timestamp
Date: 2013-01-08 22:26:39
Message-ID: 50EC9D1F.5070406@iol.ie
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 08/01/2013 22:19, Kirk Wythers wrote:
> I have a column of type TIMESTAMP, I'd like to query all records from
> 2011. If it were text I could use a partial such as:
>
> WHERE text ~ '2011'
>
> There must be a simple way to pull the year part out of a timestamp
> format. Thanks in advance.

You want the extract() function.

Ray.

--
Raymond O'Donnell :: Galway :: Ireland
rod(at)iol(dot)ie

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message James 2013-01-08 22:26:57 Installation
Previous Message Kirk Wythers 2013-01-08 22:19:59 query by partial timestamp