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 164D93A1D4C for ; Sat, 11 Dec 2004 11:55:55 +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 15873-02 for ; Sat, 11 Dec 2004 11:55:43 +0000 (GMT) Received: from joeconway.com (wsip-24-249-201-67.sd.sd.cox.net [24.249.201.67]) by svr1.postgresql.org (Postfix) with ESMTP id 1051F3A6281 for ; Sat, 11 Dec 2004 11:55:44 +0000 (GMT) Received: from [192.168.4.1] (account jconway [192.168.4.1] verified) by joeconway.com (CommuniGate Pro SMTP 4.1.8) with ESMTP-TLS id 2395480; Sat, 11 Dec 2004 03:44:45 -0800 Message-ID: <41BAE040.9040207@joeconway.com> Date: Sat, 11 Dec 2004 03:55:44 -0800 From: Joe Conway User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20040922 X-Accept-Language: en-us, en MIME-Version: 1.0 To: "Muhyiddin A.M Hayat" Cc: pgsql-sql@postgresql.org Subject: Re: Create Calendar References: <003801c4deee$451eb6c0$1f00a8c0@middinks> In-Reply-To: <003801c4deee$451eb6c0$1f00a8c0@middinks> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200412/57 X-Sequence-Number: 19677 Muhyiddin A.M Hayat wrote: > How to create Calendar using Function/View. > For example i would like to display date 2004-12-01 to 2004-12-20. > > date > ------ > 2004-12-01 > 2004-12-02 > 2004-12-03 > 2004-12-04 > 2004-12-05 > .................. > .................. > 2004-12-20 -- Use in Postgres 7.4.x and earlier. -- In Postgres 8.0.0 generate_series() is a built-in function CREATE OR REPLACE FUNCTION generate_series(int, int) RETURNS setof int AS ' BEGIN FOR i IN $1..$2 LOOP RETURN NEXT i; END LOOP; RETURN; END; ' LANGUAGE plpgsql; select '2004/12/01'::date + f1 from generate_series(0, 19) as t(f1); ?column? ------------ 2004-12-01 2004-12-02 2004-12-03 2004-12-04 2004-12-05 [...] 2004-12-20 (20 rows) HTH, Joe