While the following cast works in psql, an equivalent cast fails in plpgsql:
select cast ('Dec 14 1901 08:45:52' as timestamp);
The following equivalent plgsql function
create function rdbms_date(varchar) returns timestamp as '
declare
p_raw_date alias for $1;
begin
return cast (p_raw_date as timestamp);
end;' language 'plpgsql';
fails with error message:
ERROR: Cannot cast type 'varchar' to 'timestamp'
when called like so:
select rdbms_date('Dec 14 1901 08:45:52');
Can someone explain how to cast a varchar to a timestamp in plpgsql?
Thanks,
Bart