From: David Fetter <david@fetter.org>
To: wanpeng <wanp2005@gmail.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: DATE SQL
Date: Tue, 7 Mar 2006 08:35:11 -0800
Message-ID: <20060307163511.GD16200@fetter.org> (raw)
In-Reply-To: <01ec01c6410a$36814e00$4d06050a@WANP>
References: <01ec01c6410a$36814e00$4d06050a@WANP>
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!
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: david@fetter.org, wanp2005@gmail.com
Subject: Re: DATE SQL
In-Reply-To: <20060307163511.GD16200@fetter.org>
References: <01ec01c6410a$36814e00$4d06050a@WANP> <20060307163511.GD16200@fetter.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox