X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 954AF9DC9B6 for ; Tue, 7 Mar 2006 12:35:18 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 60538-07 for ; Tue, 7 Mar 2006 12:35:13 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from fetter.org (dsl092-188-065.sfo1.dsl.speakeasy.net [66.92.188.65]) by postgresql.org (Postfix) with ESMTP id 3DC349DCC35 for ; Tue, 7 Mar 2006 12:35:12 -0400 (AST) Received: by fetter.org (Postfix, from userid 500) id A2B87CF1CF; Tue, 7 Mar 2006 08:35:11 -0800 (PST) Date: Tue, 7 Mar 2006 08:35:11 -0800 From: David Fetter To: wanpeng Cc: pgsql-jdbc@postgresql.org Subject: Re: DATE SQL Message-ID: <20060307163511.GD16200@fetter.org> References: <01ec01c6410a$36814e00$4d06050a@WANP> Mime-Version: 1.0 Content-Type: text/plain; charset=iso_8859_1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <01ec01c6410a$36814e00$4d06050a@WANP> User-Agent: Mutt/1.4.2.1i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.129 required=5 tests=[AWL=0.129] X-Spam-Score: 0.129 X-Spam-Level: X-Archive-Number: 200603/27 X-Sequence-Number: 14808 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!