--CREATE OR REPLACE FUNCTION fnx_getFullMonth("dateX" timestamp, "dateY" timestamp)
--  RETURNS integer AS
--$BODY$	
--declare	_y int;
--Begin	
--	_y := date_part('year', "dateY")*12 + date_part('month', "dateY") - date_part('year', "dateX")*12 + date_part('month', "dateX");
--	_y := case when "dateY" < "dateX" + _y * interval '1 month' then _y - 1 else _y end;
--	_y := (	select t.dd 
--		from (VALUES(0),(1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(15),(18),(21),(24),(30),(36),(48),(60),(72),(84),(96),(108),(120),(132),(144),(156),(168),(180),(192),(204)) t(dd)
--		where t.dd >= _y
--		order by t.dd
--		limit 1
--		);
--	_y := case when _y > 204 then 204 else _y end;
--	return _y;
--END $BODY$
--  LANGUAGE plpgsql immutable;
--ALTER FUNCTION fnx_getFullMonth(timestamp, timestamp)
--  OWNER TO postgres;