pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thomas Kellerer <shammat@gmx.net>
To: pgsql-general@lists.postgresql.org
Subject: Re: TO_DATE function between PostgreSQL 8.2 and 9.4
Date: Tue, 17 May 2022 18:58:49 +0200
Message-ID: <e3ba00e9-31c8-359e-735a-83785e9bd1f1@gmx.net> (raw)
In-Reply-To: <35162944.7eee.180d2badd7c.Coremail.gzhcoder@126.com>
References: <35162944.7eee.180d2badd7c.Coremail.gzhcoder@126.com>

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.






view thread (7+ messages)  latest in thread

Message-ID: <e3ba00e9-31c8-359e-735a-83785e9bd1f1@gmx.net>
Permalink:  ../e3ba00e9-31c8-359e-735a-83785e9bd1f1@gmx.net/
Also on:    postgresql.org/message-id/e3ba00e9-31c8-359e-735a-83785e9bd1f1@gmx.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: shammat@gmx.net
  Subject: Re: TO_DATE function between PostgreSQL 8.2 and 9.4
  In-Reply-To: <e3ba00e9-31c8-359e-735a-83785e9bd1f1@gmx.net>
  References: <35162944.7eee.180d2badd7c.Coremail.gzhcoder@126.com> <e3ba00e9-31c8-359e-735a-83785e9bd1f1@gmx.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox