Re: Days in month query - Mailing list pgsql-general

From Mike Nolan
Subject Re: Days in month query
Date
Msg-id 200503310026.j2V0QXej002448@gw.tssi.com
Whole thread Raw
In response to Days in month query  (Mark Fox <mark.fox@gmail.com>)
List 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

pgsql-general by date:

Previous
From: Arthur Hoogervorst
Date:
Subject: Re: Days in month query
Next
From: Alvaro Herrera
Date:
Subject: Re: Ayuda con procesamiento en Postgres !!!!