Re: Given 02-01-2006 to 02-28-2006, output all days.

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Henry Ortega <juandelacruz(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Given 02-01-2006 to 02-28-2006, output all days.
Date: 2006-02-17 21:20:02
Message-ID: 20060217212002.GA58573@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Fri, Feb 17, 2006 at 04:07:28PM -0500, Henry Ortega wrote:
> Is there a real quick way to do a query that will show me all the dates
> given a startdate and an end date?

You could use generate_series(), which is built-in since 8.0 and
easily written in earlier versions.

SELECT date'2006-02-01' + x
FROM generate_series(0, date'2006-02-28' - date'2006-02-01') AS g(x);

--
Michael Fuhr

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Owen Jacobson 2006-02-17 23:08:11 Re: Given 02-01-2006 to 02-28-2006, output all days.
Previous Message Owen Jacobson 2006-02-17 21:14:46 Re: Given 02-01-2006 to 02-28-2006, output all days.