Re: to_timestamp, problem

From: Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
To: Marcin Mazurek <M(dot)Mazurek(at)poznan(dot)multinet(dot)pl>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: to_timestamp, problem
Date: 2000-12-15 10:49:47
Message-ID: Pine.LNX.3.96.1001215114202.4543A-100000@ara.zf.jcu.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


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 GCC 2.95.2
(1 row)

test=# SELECT to_timestamp('20000512144548', 'YYYYMMDDHHMISS');
to_timestamp
------------------------
2000-05-12 14:45:48+02
(1 row)

Karel

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message miguel sofer 2000-12-15 12:13:08 Re: How to represent a tree-structure in a relationaldatabase
Previous Message Marcin Mazurek 2000-12-15 10:30:34 to_timestamp, problem