La funziona pgsql permette di estrarre tutte le date tra una data iniziale e finale passate come parametri
Next pgsql function allow to extract all dates between start and end date passed as argument
NB: api is a schema I use to put all my function on a database instance
select api.myinterval('2005-01-01','2005-01-05') -> 2005-01-02; 2005-01-03; 2005-01-04; 2005-01-05
CREATE OR REPLACE FUNCTION api.myinterval(date, date) RETURNS SETOF date AS '
DECLARE
i_from alias for $1;
i_to alias for $2;
current date;
BEGIN
current := i_from;
RETURN NEXT current;
WHILE (i_to - current <> 0) LOOP
current:=(current + 1);
RETURN NEXT current ;
END LOOP;
RETURN;
END;
' LANGUAGE 'plpgsql' VOLATILE;
12/12/2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment