Re: query by partial timestamp

From: Rob Sargent <robjsargent(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: query by partial timestamp
Date: 2013-01-08 22:51:41
Message-ID: 50ECA2FD.302@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 01/08/2013 03:39 PM, Raymond O'Donnell wrote:
> On 08/01/2013 22:26, Raymond O'Donnell wrote:
>> 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.
>
> Sorry, meant to include the reference:
>
> http://www.postgresql.org/docs/9.2/static/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT
>
> Ray.
>
Ray, I thought you were simply encouraging the OP to learn to fish :)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Steve Crawford 2013-01-08 23:03:58 Re: query by partial timestamp
Previous Message Raymond O'Donnell 2013-01-08 22:39:58 Re: query by partial timestamp