Creating subsets on timestamp with modulo, date_trunc and ?suggestions?

From: "Davor J(dot)" <DavorJ(at)live(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Creating subsets on timestamp with modulo, date_trunc and ?suggestions?
Date: 2010-02-08 15:08:42
Message-ID: hkp9dm$eqo$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

A simple way I came up is to truncate the date. So if you have 2009-08-08,
and you want a subset on month, then just truncate the day-part: 2009-08-00
on the whole column, and SELECT DISTINCT so you have a subset. You can use
this subset then to join the dates, GROUP BY and aggregate....

An other way I found to do this is in Celko's 'SQL for smarties'. He uses
modulo there. It seems powerful, but also tricky to implement.

I was wondering if anyone knew some other way to create a subset of a
timestamp column. Any input is welcome.

Regards,
Davor

Browse pgsql-general by date

  From Date Subject
Next Message Marc Lustig 2010-02-08 15:11:28 recovering fs-data from previous installation
Previous Message Davor J. 2010-02-08 14:55:54 One column to multiple columns based on constraints?