Re: Query to find list of dates between two dates

From: "Albe Laurenz" <laurenz(dot)albe(at)wien(dot)gv(dot)at>
To: "aravind chandu *EXTERN*" <avin_friends(at)yahoo(dot)com>, "postgresql Forums" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Query to find list of dates between two dates
Date: 2010-02-05 14:59:06
Message-ID: D960CB61B694CF459DCFB4B0128514C20393814E@exadv11.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

aravind chandu wrote:
> can you please help me with the following query
>
> I need a query that displays all the dates in between two
> dates say i give two dates 12/1/2009 and 12/31/2009 The
> result should be like this
>
> 12/1/2009
> 12/2/2009
> 12/3/2009
>
> .
> .
> .
> .
> .
> 12/31/2009
>
> Note : Assume that there is no table

SELECT CAST(d AS date)
FROM generate_series(
CAST('2009-12-01' AS timestamp with time zone),
'2009-12-31',
'1 day') AS g(d);

Yours,
Laurenz Albe

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2010-02-05 15:08:11 Re: Verify a record has a column in a plpgsql trigger
Previous Message RW 2010-02-05 14:49:16 Re: Idle in Transaction