Re: TO_DATE function between PostgreSQL 8.2 and 9.4

Поиск
Список
Период
Сортировка
Искать
От
David G. Johnston
Тема
Re: TO_DATE function between PostgreSQL 8.2 and 9.4
Дата
в 16:22:44
Msg-id
CAKFQuwZCDEBBOkW3H16UneUxffh3yK1CMCtGw7i=dT4ETiPSJA@mail.gmail.com
Ответ на
Список
Дерево обсуждения
TO_DATE function between PostgreSQL 8.2 and 9.4 gzh <gzhcoder@126.com>
Re: TO_DATE function between PostgreSQL 8.2 and 9.4 Tom Lane <tgl@sss.pgh.pa.us>
Re: TO_DATE function between PostgreSQL 8.2 and 9.4 Adrian Klaver <adrian.klaver@aklaver.com>
Re: TO_DATE function between PostgreSQL 8.2 and 9.4 "David G. Johnston" <david.g.johnston@gmail.com>
Re: TO_DATE function between PostgreSQL 8.2 and 9.4 John W Higgins <wishdev@gmail.com>
Re: TO_DATE function between PostgreSQL 8.2 and 9.4 Adrian Klaver <adrian.klaver@aklaver.com>
Re: TO_DATE function between PostgreSQL 8.2 and 9.4 Thomas Kellerer <shammat@gmx.net>
On Tue, May 17, 2022 at 8:55 AM gzh <gzhcoder@126.com> wrote:

--PostgreSQL 9.4

---------------

SELECT to_date(now() + '-7day', 'YYYY-MM-DD');


--------------------------------------------------------------------------------

ERROR:  function to_date(timestamp with time zone, unknown) does not exist

LINE 1: SELECT to_date(now() + '-7day', 'YYYY-MM-DD')

                ^

********** Error **********


Is there any easy way to maintain compatibility?



You could try creating a user function named "to_date" with (timestamptz, text) as the signature and then inside the function cast the first argument to text explicitly before invoking the built-in to_date(text, text) function and returning its result.

You may have to deal with namespace/search_path issues though...
David J.

В списке pgsql-general по дате отправления
От: Tom Lane
Дата:
От: John W Higgins
Дата:
FAQ