I have written this function:
CREATE OR REPLACE FUNCTION get_date2(idate date) RETURNS date AS $$
DECLARE
tmp text;
BEGIN
SELECT to_char(idate, 'FMDDth FMMon YYYY') into tmp;
return tmp::date;
END;
$$ LANGUAGE 'plpgsql';
But when I try to use the function I get this error:
my_dbs=#select get_date2('01/02/1989');
ERROR: invalid input syntax for type date: "1st Feb 1989"
CONTEXT: PL/pgSQL function "get_date2" line 6 at RETURN
any help will be appreciated
CREATE OR REPLACE FUNCTION get_date2(idate date) RETURNS date AS $$
DECLARE
tmp text;
BEGIN
SELECT to_char(idate, 'FMDDth FMMon YYYY') into tmp;
return tmp::date;
END;
$$ LANGUAGE 'plpgsql';
But when I try to use the function I get this error:
my_dbs=#select get_date2('01/02/1989');
ERROR: invalid input syntax for type date: "1st Feb 1989"
CONTEXT: PL/pgSQL function "get_date2" line 6 at RETURN
any help will be appreciated