Re: BUG #17305: to_timestamp accept dates rejected by timestamptz cast

From: Chinh Nguyen <nguyenkhacchinh(at)hotmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #17305: to_timestamp accept dates rejected by timestamptz cast
Date: 2021-12-03 15:06:23
Message-ID: DM6PR02MB67940A966A28BAD4E7358194A46A9@DM6PR02MB6794.namprd02.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

I am simply going by this tip in the documentation:

"to_timestamp and to_date exist to handle input formats that cannot be converted by simple casting. For most standard date/time formats, simply casting the source string to the required data type works, and is much easier. Similarly, to_number is unnecessary for standard numeric representations."

It's interesting that 0000-02-31 is acceptable for one but not the other. But given the unlikelihood of seeing this date in data that I process, this behaviour is simply a curiosity.

Regards.
________________________________
From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Sent: December 2, 2021 1:54 PM
To: nguyenkhacchinh(at)hotmail(dot)com <nguyenkhacchinh(at)hotmail(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #17305: to_timestamp accept dates rejected by timestamptz cast

PG Bug reporting form <noreply(at)postgresql(dot)org> writes:
> I don't know if this is a bug or just an unusual behavior. I had assumed,
> per the documentation, that function to_timestamp() is the same as
> timestamptz but with control for different formats.

It is not, and I don't see the documentation claiming that it is.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2021-12-03 15:33:02 BUG #17313: Exception by opening and closing connection
Previous Message Daniel Gustafsson 2021-12-03 13:38:06 Re: BUG #17311: Google search results: Outdated docs at the top