Search Postgresql Archives

Re: pulling year out of a timestamp

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux