X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3F6638B9BBB for ; Wed, 2 Feb 2005 02:53:33 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 40860-04 for ; Wed, 2 Feb 2005 02:53:25 +0000 (GMT) Received: from smtp-1.indo.net.id (smtp-1.indo.net.id [202.159.32.91]) by svr1.postgresql.org (Postfix) with SMTP id 624438B9B5B for ; Wed, 2 Feb 2005 02:53:21 +0000 (GMT) Received: (qmail 14468 invoked from network); 2 Feb 2005 09:53:18 +0700 Received: from smtp.indo.net.id (202.159.32.81) by smtp-1.indo.net.id with SMTP; 2 Feb 2005 09:53:18 +0700 Received: (qmail 3765 invoked from network); 2 Feb 2005 09:53:15 +0700 Received: from unknown (HELO middinks) (202.159.122.97) by smtp.indo.net.id with SMTP; 2 Feb 2005 09:53:15 +0700 Message-ID: <018901c508d2$55bc3800$1f00a8c0@middinks> From: "Muhyiddin A.M Hayat" To: "Franco Bruno Borghesi" Cc: References: <03a001c50545$6bd942d0$1f00a8c0@middinks> <41FA5E6A.50002@akyasociados.com.ar> Subject: Re: Calendar Function Date: Wed, 2 Feb 2005 10:53:09 +0800 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0186_01C50915.621391A0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.44 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_WHOIS, HTML_60_70, HTML_MESSAGE, HTML_TITLE_EMPTY X-Spam-Level: X-Archive-Number: 200502/37 X-Sequence-Number: 20148 This is a multi-part message in MIME format. ------=_NextPart_000_0186_01C50915.621391A0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Ok, thanks But if i would like to display date in one Month, e.g : date in feb 2005 calendar ------------ 2005-02-01 2005-02-02 2005-02-03 2005-02-04 2005-02-05 2005-02-06 2005-02-07 2005-02-08 2005-02-09 2005-02-10 2005-02-11 2005-02-12 2005-02-13 2005-02-14 2005-02-15 2005-02-16 2005-02-17 2005-02-18 2005-02-19 2005-02-20 2005-02-21 2005-02-22 2005-02-23 2005-02-24 2005-02-25 2005-02-26 2005-02-27 2005-02-28 date in feb 2004 calendar ------------ 2004-02-01 2004-02-02 2004-02-03 2004-02-04 2004-02-05 2004-02-06 2004-02-07 2004-02-08 2004-02-09 2004-02-10 2004-02-11 2004-02-12 2004-02-13 2004-02-14 2004-02-15 2004-02-16 2004-02-17 2004-02-18 2004-02-19 2004-02-20 2004-02-21 2004-02-22 2004-02-23 2004-02-24 2004-02-25 2004-02-26 2004-02-27 2004-02-28 2004-02-29 ----- Original Message -----=20 From: Franco Bruno Borghesi=20 To: Muhyiddin A.M Hayat=20 Cc: pgsql-sql@postgresql.org=20 Sent: Friday, January 28, 2005 11:46 PM Subject: Re: [SQL] Calendar Function 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<=3Dv_to) LOOP=20 RETURN NEXT v_current; v_current:=3Dv_current+1; END LOOP; =20 RETURN; END; '; test it: SELECT * FROM calendar('2005-01-01', '2005-01-31'); Muhyiddin A.M Hayat wrote:=20 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 ------=_NextPart_000_0186_01C50915.621391A0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Ok, thanks
 
But if i would like to display date in one Month,
 
 e.g :
date in feb 2005
 
 =20 calendar
------------
 2005-02-01
 2005-02-02
 = ;2005-02-03
 2005-02-04
 2005-02-05
 2005-02-06 2005-02-07
 2005-02-08
 2005-02-09
 2005-= 02-10
 2005-02-11
 2005-02-12
 2005-02-13
&nbs= p;2005-02-14
 2005-02-15
 2005-02-16
 2005-02-17<= BR> 2005-02-18
 2005-02-19
 2005-02-20
 2005= -02-21
 2005-02-22
 2005-02-23
 2005-02-24
&nb= sp;2005-02-25
 2005-02-26
 2005-02-27
 2005-02-28=
 
date in feb 2004
 
 =20 calendar
------------
 2004-02-01
 2004-02-02
 = ;2004-02-03
 2004-02-04
 2004-02-05
 2004-02-06 2004-02-07
 2004-02-08
 2004-02-09
 2004-= 02-10
 2004-02-11
 2004-02-12
 2004-02-13
&nbs= p;2004-02-14
 2004-02-15
 2004-02-16
 2004-02-17<= BR> 2004-02-18
 2004-02-19
 2004-02-20
 2004= -02-21
 2004-02-22
 2004-02-23
 2004-02-24
&nb= sp;2004-02-25
 2004-02-26
 2004-02-27
 2004-02-28=
 2004-02-29
 
----- Original Message -----
From:=20 Franco Bruno Borghesi =
Sent: Friday, January 28, 2005 = 11:46=20 PM
Subject: Re: [SQL] Calendar=20 Function

maybe somthing like this:

CREATE OR REPLACE = FUNCTION=20 calendar (DATE, DATE) RETURNS SETOF DATE LANGUAGE 'plpgsql' AS=20 '
DECLARE
    v_from ALIAS FOR = $1;
   =20 v_to ALIAS FOR $2;
    v_current DATE DEFAULT=20 v_from;
BEGIN
    WHILE (v_current<=3Dv_to) = LOOP=20
        RETURN NEXT=20 v_current;
       =20 v_current:=3Dv_current+1;
    END = LOOP;
   =20
    RETURN;
END;
';

test it:
SELECT = * FROM=20 calendar('2005-01-01', '2005-01-31');


Muhyiddin A.M Hayat = wrote:=20
Dear All,
 
How to create Calendar Function or = Query. I=20 would like to display date form yyyy-mm-dd to yyyy-mm-dd or display = date in=20 one Month
 
e.g:
 
   =20 = date
------------
 2005-01-01
 2005-01-02
 200= 5-01-03
 2005-01-04
 2005-01-05
 2005-01-06
&n= bsp;2005-01-07
 2005-01-08
 2005-01-09
 2005-01-1= 0
 2005-01-11
 2005-01-12
 2005-01-13
 20= 05-01-14
 2005-01-15
 2005-01-16
 2005-01-17
&= nbsp;2005-01-18
 2005-01-19
 2005-01-20
 2005-01-= 21
 2005-01-22
 2005-01-23
 2005-01-24
 2= 005-01-25
 2005-01-26
 2005-01-27
 2005-01-28
=  2005-01-29
 2005-01-30
 2005-01-31
 
 

------=_NextPart_000_0186_01C50915.621391A0--