Re: Bug in to_timestamp()

From: Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
To: pgsql-hackers <pgsql-hackers(at)postgreSQL(dot)org>, Gqms2 Galway <gqms2(at)nortelnetworks(dot)com>
Cc: "'pgsql-bugs(at)postgresql(dot)org'" <pgsql-bugs(at)postgreSQL(dot)org>
Subject: Re: Bug in to_timestamp()
Date: 2000-08-17 10:47:43
Message-ID: Pine.LNX.3.96.1000817122143.31414E-100000@ara.zf.jcu.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On Wed, 16 Aug 2000, Gqms2 Galway wrote:

>
> Please enter a FULL description of your problem:
> ------------------------------------------------
> The to_timestamp function is not working as per the documentation. See the
> examples below.
>

No. It is not bug. Where is in a documentation your example?

Instead this, in the documentation is next:

YYYY = year (4 or more digits)
^^^^^^^^^^^

Timestamp range is 4714 BC -- 1465001 AC.

> select to_timestamp('20000816000001', 'YYYYMMDDHH24MISS') returns
> '30/12/1899' (wrong)

The PostgreSQL hasn't directly limited year. The to_timestamp() stop
parse YYYY at first non-digit char.

> select to_timestamp('2000 0816000001', 'YYYY MMDDHH24MISS') returns
> '16/08/2000 00:00:01' (ok)

Yes, it's right.

If you want store full timestamp into one big number is better year
keep to end of this number, like:

test=# select to_timestamp('08160000012000', 'MMDDHH24MISSYYYY');
to_timestamp
------------------------
2000-08-16 00:00:01+02

And YYY, YY, Y ... it's *hell*, and we support it because Oracle has it
too. How number you want create from:

'01' -- 'YY' ---> 2001, 1901 or 0001 .. grrrr

to_timestamp() use last possibility.

Some commets/suggestions about greater years than 9999 in
to_timestamp() / to_date()?

Thanks,
Karel

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Bob Rivoir 2000-08-18 02:32:41 INSERT/SELECT with ORDER BY
Previous Message Stephan Szabo 2000-08-17 06:19:20 Re: [BUGS] help me

Browse pgsql-hackers by date

  From Date Subject
Next Message Karel Zak 2000-08-17 11:17:50 right RULE?
Previous Message Patrick Welche 2000-08-17 10:46:56 Re: Regression Tests