Re: Generating a list of days - Mailing list pgsql-general

From Thomas Lockhart
Subject Re: Generating a list of days
Date
Msg-id 3C98B1C8.3B65AEA6@fourpalms.org
Whole thread Raw
In response to Generating a list of days  (Fraser Murray <frasernm@yahoo.co.uk>)
Responses Re: Generating a list of days  (Ron Mahoney <rmahoney@infotech-nj.com>)
List pgsql-general
> I'm trying to generate a list of days between a start
> date and an end date for use in a query - I would then
> do an outer join with some other data for graphing
> purposes as I need all the days with 0 entries.

istm that you would be able to simply qualify your query with a

WHERE your_date_column BETWEEN 'your_start_date" AND 'your_end_date'

You can use GROUP BY/HAVING to get missing results, or just select on
the NULL columns in the outer join you have already suggested.

If you put the date column in the output also then you would have the
list available at that point.

If you are using perl and actually want a complete list of the *missing*
dates, which is of course what you said you wanted, I would suggest
doing the above query (which can be efficient) and then generate the
list of missing dates using perl (which is also efficient generating a
list).

Folks may have other good suggestions too...

hth

                      - Thomas

pgsql-general by date:

Previous
From: Jeff Eckermann
Date:
Subject: Re: How to create crude report with psql and/or plpgsql
Next
From: Thomas Lockhart
Date:
Subject: Re: Bad timestamp external representation '2001-05-11