Home
The Toolkit for Online Communities
13502 Community Members, 0 members online, 2094 visitors today
Log In Register

Forum OpenACS Development: How to select all dates on Postgres?

OpenACS Home : Forums : OpenACS Development : How to select all dates on Postgres?

Icon of Envelope Request notifications

+
Posted by Jade Rubick on
Hi all:

In Oracle, there are a few tricks you can use to dynamically select all the date values between two dates.

Does anyone know how to do this in Postgres?

I'd like to do an outer join against all dates between two ranges, so that I can graph values that include dates with data and those without.

Any ideas?

Thanks,
Jade

+
Posted by Jade Rubick on
Here's one example of one way to do it in Oracle:
http://halisway.blogspot.com/2006/12/date-range-generation-in-oracle.html

I've seen a lot of others as well -- Tom Kyte posted on this I believe.

+
Posted by Steve Manning on

Jade

If its a Postgres 8+ then its trivial using the generate_series() function  see http://www.postgresql.org/docs/8.0/interactive/functions-srf.html

e.g

select current_date + s.a as dates from generate_series(0,14,7) as s(a);
   dates
------------
 2004-02-05
 2004-02-12
 2004-02-19

(3 rows)

 I don't think this function was available before 8 but it may be possible to hand craft your own version.

 
    - Steve