Re: DATE SQL - Mailing list pgsql-jdbc

From David Fetter
Subject Re: DATE SQL
Date
Msg-id 20060307163511.GD16200@fetter.org
Whole thread Raw
In response to DATE SQL  ("wanpeng" <wanp2005@gmail.com>)
List pgsql-jdbc
On Mon, Mar 06, 2006 at 06:39:09PM +0800, wanpeng wrote:
> I want a result like
>
> '2006-03-01'
> '2006-03-02'
> '2006-03-03'
> '2006-03-04'
>
>
> FROM table xxx
>
> ¡­¡­| start_date   |   end_date   |¡­¡­
>     | '2006-03-01' |  '2006-03-04'|
>
> how can I write the sql

No problem if you're willing to use one of PostgreSQL's built-in
set-returning functions in your target list.

SELECT (
    start_date +
    generate_series(0,end_date-start_date) * interval '1 day'
    )::date AS "range"
FROM your_table;

Cheers,
D
--
David Fetter david@fetter.org http://fetter.org/
phone: +1 415 235 3778

Remember to vote!

pgsql-jdbc by date:

Previous
From: Mark Lewis
Date:
Subject: Re: DATE SQL
Next
From: "Rajeev Menon"
Date:
Subject: Connection String