pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #15351: to_date() function bug
2+ messages / 2 participants
[nested] [flat]

* BUG #15351: to_date() function bug
@ 2018-08-24 15:42 PG Bug reporting form <noreply@postgresql.org>
  2018-08-24 16:08 ` Re: BUG #15351: to_date() function bug Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 2+ messages in thread

From: PG Bug reporting form @ 2018-08-24 15:42 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: infinite77derger@gmail.com

The following bug has been logged on the website:

Bug reference:      15351
Logged by:          Василий Пупкин
Email address:      infinite77derger@gmail.com
PostgreSQL version: 10.4
Operating system:   Ubuntu
Description:        

Hi!
I have version: PostgreSQL 10.4 (Debian 10.4-2.pgdg90+1) on
x86_64-pc-linux-gnu, compiled by gcc (Debian 6.3.0-18+deb9u1) 6.3.0
20170516, 64-bit

And there is a bug in to_date()  function:

All dates, that are less then '04.01.0001', returns in Before Christ (!)
format.

Examples:
SELECT to_date('01.12.0000', 'DD.MM.YYYY'); - -   converts to 0001-12-01 BC
(Before Christ)
SELECT to_date('01.01.0000', 'DD.MM.YYYY'); - -   converts to 0001-01-01
BC
SELECT to_date('01.01.0001', 'DD.MM.YYYY'); - -   converts to 0001-01-01
BC
SELECT to_date('01.01.0001 whatever', 'DD.MM.YYYY'); - -  converts to
0001-01-01 BC
SELECT  to_date('', 'DD.MM.YYYY'); - - empty text also converts to
0001-01-01 BC

SELECT to_date('03.01.0001', 'DD.MM.YYYY'); - - converts to 0001-01-03 BC
But
SELECT to_date('04.01.0001', 'DD.MM.YYYY'); - - converts to 0001-01-04 -
correct



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #15351: to_date() function bug
  2018-08-24 15:42 BUG #15351: to_date() function bug PG Bug reporting form <noreply@postgresql.org>
@ 2018-08-24 16:08 ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2018-08-24 16:08 UTC (permalink / raw)
  To: infinite77derger@gmail.com; +Cc: pgsql-bugs@lists.postgresql.org

=?utf-8?q?PG_Bug_reporting_form?= <noreply@postgresql.org> writes:
> All dates, that are less then '04.01.0001', returns in Before Christ (!)
> format.

Can't reproduce that here ...

> Examples:
> SELECT to_date('01.12.0000', 'DD.MM.YYYY'); - -   converts to 0001-12-01 BC
> (Before Christ)
> SELECT to_date('01.01.0000', 'DD.MM.YYYY'); - -   converts to 0001-01-01
> BC

Neither of the above are surprising.  There's no year zero in the
Gregorian calendar.  We could throw an error for that input, perhaps,
but what the code chooses to do is interpret it as 1BC.

> SELECT to_date('01.01.0001', 'DD.MM.YYYY'); - -   converts to 0001-01-01
> BC

That would be a bug, I agree, but I can't reproduce it here.  I get

regression=# SELECT to_date('01.01.0001', 'DD.MM.YYYY');
  to_date   
------------
 0001-01-01
(1 row)

and likewise for your other funny cases.  I wonder whether you're
using a stock build of Postgres --- or maybe you're running into
compiler bugs?  Where did you get PG from?

> SELECT  to_date('', 'DD.MM.YYYY'); - - empty text also converts to
> 0001-01-01 BC

That seems all right given the interpretation of zeroes.  There's probably
a market for a version of to_date that's more willing to throw errors for
questionable input ... but that's not how to_date itself has traditionally
worked.

			regards, tom lane




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2018-08-24 16:08 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-08-24 15:42 BUG #15351: to_date() function bug PG Bug reporting form <noreply@postgresql.org>
2018-08-24 16:08 ` Tom Lane <tgl@sss.pgh.pa.us>

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