pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Muhyiddin A.M Hayat <middink@indo.net.id>
To: Franco Bruno Borghesi <franco@akyasociados.com.ar>
Cc: pgsql-sql@postgresql.org
Subject: Re: Calendar Function
Date: Wed, 2 Feb 2005 10:53:09 +0800
Message-ID: <018901c508d2$55bc3800$1f00a8c0@middinks> (raw)
References: <03a001c50545$6bd942d0$1f00a8c0@middinks>
	<41FA5E6A.50002@akyasociados.com.ar>

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 ----- 
  From: Franco Bruno Borghesi 
  To: Muhyiddin A.M Hayat 
  Cc: pgsql-sql@postgresql.org 
  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<=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

view thread (6+ messages)  latest in thread

Message-ID: <018901c508d2$55bc3800$1f00a8c0@middinks>
Permalink:  ../018901c508d2$55bc3800$1f00a8c0@middinks/
Also on:    postgresql.org/message-id/018901c508d2$55bc3800$1f00a8c0@middinks

 · 

reply

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: middink@indo.net.id, franco@akyasociados.com.ar
  Subject: Re: Calendar Function
  In-Reply-To: <018901c508d2$55bc3800$1f00a8c0@middinks>

* 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