Re: Days in month query

From: Mike Nolan <nolan(at)gw(dot)tssi(dot)com>
To: pgsql-general(at)postgresql(dot)org (pgsql general list)
Subject: Re: Days in month query
Date: 2005-03-31 00:26:32
Message-ID: 200503310026.j2V0QXej002448@gw.tssi.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> > What I want is SELECT statement that references no tables but returns
> > the days in a given month. I'm now thinking that I might be able to
> > come up with something using an IN clause and using EXTRACT, but
> > haven't figured it out yet.

I have a 'last_day' function (duplicating what the equivalent Oracle
function does), from that you can extract the number of days in the month.

Here's my 'last_day' function:

create or replace function public.last_day(date)
returns date as
'
DECLARE
this_day alias for $1;
declare wk_day date;
BEGIN

wk_day := date_trunc(''month'', this_day) + interval ''1 month''
- interval ''1 day'';
return wk_day;
END
' language 'plpgsql';
--
Mike Nolan

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2005-03-31 00:40:31 Re: Ayuda con procesamiento en Postgres !!!!
Previous Message Arthur Hoogervorst 2005-03-31 00:16:53 Re: Days in month query