Re: to_timestamp error between postgres version 8.3 and 9.2

From: françois Figarola <francois(dot)figarola(at)laposte(dot)net>
To: pgsql-admin(at)postgresql(dot)org
Subject: Re: to_timestamp error between postgres version 8.3 and 9.2
Date: 2013-08-31 05:52:24
Message-ID: 52218498.6020302@laposte.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

I think it's only a syntax problem :

to_timestamp('null','yyyy-MM-ddhh24:mi:ss')::TIMESTAMP

In this form your 'null' parameter is a text which dont match for your
definition, so the function is waiting for an integer representing the
year and fails.

But if you write :

to_timestamp(null,'yyyy-MM-ddhh24:mi:ss')::TIMESTAMP

the function return a NULL value.

Hope it helps.

Le 31/08/2013 07:19, Technical Doubts a écrit :
>
> Dear Team,
>
> I have a table with name registers_info with below columns
>
> regid character varying,
> transid bigint,
> regdate timestamp without time zone,
> canceldate timestamp without time zone
>
>
> insert into registers_info (regid,transid,regdate,canceldate) values
> ('reg1',1,to_timestamp('2013-07-24','yyyy-MM-dd
> hh24:mi:ss')::TIMESTAMP,to_timestamp('null','yyyy-MM-dd
> hh24:mi:ss')::TIMESTAMP);
>
> The above query works fine in Postgres 8.3 version.
>
> But the same query when executed in postgres 9.2 its throwing below error
>
> ERROR: invalid value "null" for "yyyy"
> Detail: Value must be an integer.
>
> From application, this cancel date might have values or it may come as null.
>
> Kindly suggest. Thanks in advance.
>
>
> --
> John

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Patrick Dung 2013-09-01 09:33:33 Re: several questions about pg_dumpall, pg_start_backup, pg_basebackup and WAL
Previous Message Tom Lane 2013-08-31 05:47:00 Re: to_timestamp error between postgres version 8.3 and 9.2