Good Morning,
On Tue, May 17, 2022 at 8:55 AM gzh <gzhcoder@xxxxxxx> wrote:
Hi,
--------------------------------------------------------------------------------
ERROR: function to_date(timestamp with time zone, unknown) does not exist
LINE 1: SELECT to_date(now() + '-7day', 'YYYY-MM-DD')
^
********** Error **********
Of course, the most reliable way to deal with it is to
rewrite the application or SQL to handle types strictly,
but the application is large and rewrite is a terrible job.
Is there any easy way to maintain compatibility?
Just create the missing function
create function to_date(timestamp with time zone, text) RETURNS text AS
'SELECT to_date($1::text, $2)::text'
LANGUAGE SQL
IMMUTABLE;
(see https://www.db-fiddle.com/f/w5WYLgsiFLv3jm7hhJ7dsH/0 for a working example)
John