Re: to_timestamp, problem - Mailing list pgsql-sql

From Karel Zak
Subject Re: to_timestamp, problem
Date
Msg-id Pine.LNX.3.96.1001215114202.4543A-100000@ara.zf.jcu.cz
Whole thread Raw
In response to to_timestamp, problem  (Marcin Mazurek <M.Mazurek@poznan.multinet.pl>)
List 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
GCC2.95.2
 
(1 row)

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



pgsql-sql by date:

Previous
From: Marcin Mazurek
Date:
Subject: to_timestamp, problem
Next
From: miguel sofer
Date:
Subject: Re: How to represent a tree-structure in a relationaldatabase