From: Franco Bruno Borghesi <franco@akyasociados.com.ar>
To: Muhyiddin A.M Hayat <middink@indo.net.id>
Cc: pgsql-sql@postgresql.org
Subject: Re: Calendar Function
Date: Fri, 28 Jan 2005 12:46:50 -0300
Message-ID: <41FA5E6A.50002@akyasociados.com.ar> (raw)
In-Reply-To: <03a001c50545$6bd942d0$1f00a8c0@middinks>
References: <03a001c50545$6bd942d0$1f00a8c0@middinks>
maybe somthing like this:
CREATE OR REPLACE FUNCTION calendar (DATE, DATE) RETURNS SETOF DATE
LANGUAGE 'plpgsql' AS '
DECLARE
v_from ALIAS FOR $1;
v_to ALIAS FOR $2;
v_current DATE DEFAULT v_from;
BEGIN
WHILE (v_current<=v_to) LOOP
RETURN NEXT v_current;
v_current:=v_current+1;
END LOOP;
RETURN;
END;
';
test it:
SELECT * FROM calendar('2005-01-01', '2005-01-31');
Muhyiddin A.M Hayat wrote:
> Dear All,
>
> How to create Calendar Function or Query. I would like to display date
> form yyyy-mm-dd to yyyy-mm-dd or display date in one Month
>
> e.g:
>
> date
> ------------
> 2005-01-01
> 2005-01-02
> 2005-01-03
> 2005-01-04
> 2005-01-05
> 2005-01-06
> 2005-01-07
> 2005-01-08
> 2005-01-09
> 2005-01-10
> 2005-01-11
> 2005-01-12
> 2005-01-13
> 2005-01-14
> 2005-01-15
> 2005-01-16
> 2005-01-17
> 2005-01-18
> 2005-01-19
> 2005-01-20
> 2005-01-21
> 2005-01-22
> 2005-01-23
> 2005-01-24
> 2005-01-25
> 2005-01-26
> 2005-01-27
> 2005-01-28
> 2005-01-29
> 2005-01-30
> 2005-01-31
>
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: franco@akyasociados.com.ar, middink@indo.net.id
Subject: Re: Calendar Function
In-Reply-To: <41FA5E6A.50002@akyasociados.com.ar>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox