Re: TO_DATE function between PostgreSQL 8.2 and 9.4

From: Thomas Kellerer <shammat(at)gmx(dot)net>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: TO_DATE function between PostgreSQL 8.2 and 9.4
Date: 2022-05-17 16:58:49
Message-ID: e3ba00e9-31c8-359e-735a-83785e9bd1f1@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

gzh schrieb am 17.05.2022 um 17:55:
> I have had a Perl Website working for 7 years and have had no problems
>
> until at the weekend I replace my database server with a newer one.
>
> Database server (old): PostgreSQL 8.2 32bit
>
> Database server (new): PostgreSQL 9.4 64bit
>
> I run following sql in PostgreSQL 8.2, it return my expected result as ‘YYYY-MM-DD’ format.
>
>
> --PostgreSQL 8.2
>
> ---------------
>
> SELECT to_date(now() + '-7day', 'YYYY-MM-DD');

Calling to_date() on a value that is already a date or timestamp value is a huge mistake to begin with (and as you found out a bug waiting to happen).

That should have been current_date + 7 from day one.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2022-05-17 18:11:49 Re: TO_DATE function between PostgreSQL 8.2 and 9.4
Previous Message John W Higgins 2022-05-17 16:23:05 Re: TO_DATE function between PostgreSQL 8.2 and 9.4