Re: grouping by date

From: Robert Creager <Robert_Creager(at)LogicalChaos(dot)org>
To: teknokrat(at)yahoo(dot)com
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: grouping by date
Date: 2004-01-09 04:59:58
Message-ID: 20040108215958.791d131c.Robert_Creager@LogicalChaos.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

When grilled further on (Mon, 05 Jan 2004 17:14:26 +0000),
teknokrat <teknokrat(at)yahoo(dot)com> confessed:

> How can I group by date given a timestamp column?
>

I just found this out this weekend. Try 'date_trunc'. Look at secion 9.8.2 of
the documentation. I'm using something like:

SELECT date_trunc( 'hour', "when" ) AS "date" FROM readings GROUP BY "date";

Where "when" is my timestamp columnn.

Cheers,
Rob

--
21:55:40 up 11 days, 11:46, 4 users, load average: 2.09, 2.03, 2.01

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message David Witham 2004-01-09 05:23:54 Left outer join on multiple tables
Previous Message Michael Glaesemann 2004-01-09 04:49:45 Re: COPY command