Re: How to get list of days between two dates? - Mailing list pgsql-sql

From Scott Marlowe
Subject Re: How to get list of days between two dates?
Date
Msg-id 1149628942.25526.232.camel@state.g2switchworks.com
Whole thread Raw
In response to Re: How to get list of days between two dates?  ("Aaron Bono" <postgresql@aranya.com>)
List pgsql-sql
On Tue, 2006-06-06 at 16:17, Aaron Bono wrote:
> Though there may be a more eligant way to do it, when we did things
> like this in the past we created a function (or stored procedure) that
> got the min and max dates and then created a result set that iterated
> through the dates to create a virtual table of days.  Then you can
> inner join that list of days with your physical table. 

If you're on a version of pgsql with generate_series, you can use that
to easily create a pivoting data set on the fly to do this.

If you're on an older version, it's easy enough to make a generic pivot
table and keep it around to do these things.  Since we're still on 7.4
where I work, we use the pre-populated pivot table.  It's primitive, but
it works.


pgsql-sql by date:

Previous
From: "Aaron Bono"
Date:
Subject: Re: How to get list of days between two dates?
Next
From: Richard Broersma Jr
Date:
Subject: Re: How To Exclude True Values