| From: | Franco Bruno Borghesi <franco(at)akyasociados(dot)com(dot)ar> | 
|---|---|
| To: | "Muhyiddin A(dot)M Hayat" <middink(at)indo(dot)net(dot)id> | 
| Cc: | pgsql-sql(at)postgresql(dot)org | 
| Subject: | Re: Calendar Function | 
| Date: | 2005-01-28 15:46:50 | 
| Message-ID: | 41FA5E6A.50002@akyasociados.com.ar | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-sql | 
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
>  
>  
| From | Date | Subject | |
|---|---|---|---|
| Next Message | John DeSoi | 2005-01-28 21:02:13 | plpgsql select into with multiple target variables | 
| Previous Message | Michael Glaesemann | 2005-01-28 15:04:30 | Re: error: cast the timestam expression |