Re: pulling year out of a timestamp

From: Ryan Kelly <rpkelly22(at)gmail(dot)com>
To: Kirk Wythers <wythe001(at)umn(dot)edu>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: pulling year out of a timestamp
Date: 2013-04-11 15:55:18
Message-ID: 20130411155518.GB13565@llserver.lakeliving.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Apr 04/11/13, 2013 at 10:50:53AM -0500, Kirk Wythers wrote:
> I am trying to perform a join between two tables where I need to join "year" in table 1 with the year component of a timestamp in table 2.
>
> Something like this:
>
> table1.year = table2.timestamp
> where timestamp has the format: "2009-01-01 00:00:00"
>
> I've tried
>
> date_trunc('year', table2.timestamp) = table1.year

You want date_part, not date_trunc.

-Ryan

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Kirk Wythers 2013-04-11 16:09:11 Re: pulling year out of a timestamp
Previous Message Kirk Wythers 2013-04-11 15:50:53 pulling year out of a timestamp