On Fri, 15 Dec 2000, Marcin Mazurek wrote:
> Hi,
> Can anyone explain to me why this doesn't work. Seems to be some stupid (my)
> mistake:
>
> mtldb=# SELECT to_timestamp('05121445482000', 'MMDDHHMISSYYYY');
> to_timestamp
> ------------------------
> 2000-05-12 14:45:48+02
> (1 row)
>
> mtldb=# SELECT to_timestamp('20000512144548', 'YYYYMMDDHHMISS');
> to_timestamp
> --------------
> invalid
> (1 row)
>
> pg 7.0.3, linux 2.2
You are right. It is already know bug (feature:-) in 7.0.x, in this
version, to_timestamp() expect that year not must be exactly
4-digits but can be greater. A solution is use some separator like
'YYYY-MMDDHHMISS' or use YYYY as last in format template (as in your
first example).
In 7.1 is better analyse that fix it:
test=# SELECT version(); version
------------------------------------------------------------------PostgreSQL 7.1devel on i686-pc-linux-gnu, compiled by
GCC2.95.2
(1 row)
test=# SELECT to_timestamp('20000512144548', 'YYYYMMDDHHMISS'); to_timestamp
------------------------2000-05-12 14:45:48+02
(1 row)
Karel