Re: DATE SQL

From: David Fetter <david(at)fetter(dot)org>
To: wanpeng <wanp2005(at)gmail(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: DATE SQL
Date: 2006-03-07 16:35:11
Message-ID: 20060307163511.GD16200@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)fetter(dot)org http://fetter.org/
phone: +1 415 235 3778

Remember to vote!

In response to

  • DATE SQL at 2006-03-06 10:39:09 from wanpeng

Browse pgsql-jdbc by date

  From Date Subject
Next Message Rajeev Menon 2006-03-08 08:24:27 Connection String
Previous Message Mark Lewis 2006-03-06 17:04:10 Re: DATE SQL