create or replace function mdy(p_month int, p_day int, p_year int) returns date language plpgsql as $$ declare ret_mdy date; begin SELECT TO_DATE(p_year::varchar||LPAD(p_month::varchar, 2, '0')||p_day::varchar,'YYYYMMDD') into ret_mdy; return ret_mdy; end;$$