Re: Days in month query

From: "Dann Corbit" <DCorbit(at)connx(dot)com>
To: "Mark Fox" <mark(dot)fox(at)gmail(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Days in month query
Date: 2005-03-30 23:16:19
Message-ID: D425483C2C5C9F49B5B7A41F89441547055A4C@postal.corporate.connx.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

The online documentation has a search function. It would lead you to
this:
http://www.postgresql.org/docs/8.0/static/functions-datetime.html

-----Original Message-----
From: pgsql-general-owner(at)postgresql(dot)org
[mailto:pgsql-general-owner(at)postgresql(dot)org] On Behalf Of Mark Fox
Sent: Wednesday, March 30, 2005 3:07 PM
To: pgsql-general(at)postgresql(dot)org
Subject: [GENERAL] Days in month query

Greetings,

This is more of an SQL question, but since each database server seems
to use it's own syntax for handling dates...

Is there a way to query for the days in a month? For example,
querying for the days in January of this year? Listing the days
between two dates would be useful as well.

I'm sure I saw a query like this somewhere, but I can't track it down.
Just to be clear, there were no tables involved. Just a SELECT
statement that returned all the days in a given month.

Basically, I have a table of "events" and I'd like to generate a
histogram of how many events occur on the days of a particular month.
What I do now is create a temporary table, fill it with the
appropriate days, and then do a cross join and summation to generate
what I need. This works, but seems messy to me.

Mark

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2005-03-30 23:17:37 Re: Debugging deadlocks
Previous Message Mark Fox 2005-03-30 23:06:38 Days in month query