pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
to_timestamp error between postgres version 8.3 and 9.2
3+ messages / 3 participants
[nested] [flat]

* to_timestamp error between postgres version 8.3 and 9.2
@ 2013-08-31 05:19 Technical Doubts <online.technicaldoubts@gmail.com>
  2013-08-31 05:47 ` Re: to_timestamp error between postgres version 8.3 and 9.2 Tom Lane <tgl@sss.pgh.pa.us>
  2013-08-31 05:52 ` Re: to_timestamp error between postgres version 8.3 and 9.2 françois Figarola <francois.figarola@laposte.net>
  0 siblings, 2 replies; 3+ messages in thread

From: Technical Doubts @ 2013-08-31 05:19 UTC (permalink / raw)
  To: pgsql-admin

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.

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: to_timestamp error between postgres version 8.3 and 9.2
  2013-08-31 05:19 to_timestamp error between postgres version 8.3 and 9.2 Technical Doubts <online.technicaldoubts@gmail.com>
@ 2013-08-31 05:47 ` Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 0 replies; 3+ messages in thread

From: Tom Lane @ 2013-08-31 05:47 UTC (permalink / raw)
  To: Technical Doubts <online.technicaldoubts@gmail.com>; +Cc: pgsql-admin

Technical Doubts <online.technicaldoubts@gmail.com> writes:
> 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.

Yup.  It was never intended that 'null' would be valid input for
to_timestamp, and that's thrown an error since 8.4.  See thread here:
http://www.postgresql.org/message-id/37ed240d0808291839t21e19956mdfbdc80aeb1b3c19@mail.gmail.com

A quick test says that 8.3 and older did this:

regression=# select to_timestamp('null','yyyy-MM-dd hh24:mi:ss');
       to_timestamp        
---------------------------
 0001-01-01 00:00:00-05 BC
(1 row)

which can hardly be considered a sane interpretation of 'null', even
if we wanted to accept that input.

			regards, tom lane


-- 
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: to_timestamp error between postgres version 8.3 and 9.2
  2013-08-31 05:19 to_timestamp error between postgres version 8.3 and 9.2 Technical Doubts <online.technicaldoubts@gmail.com>
@ 2013-08-31 05:52 ` françois Figarola <francois.figarola@laposte.net>
  1 sibling, 0 replies; 3+ messages in thread

From: françois Figarola @ 2013-08-31 05:52 UTC (permalink / raw)
  To: 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



-- 
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2013-08-31 05:52 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2013-08-31 05:19 to_timestamp error between postgres version 8.3 and 9.2 Technical Doubts <online.technicaldoubts@gmail.com>
2013-08-31 05:47 ` Tom Lane <tgl@sss.pgh.pa.us>
2013-08-31 05:52 ` françois Figarola <francois.figarola@laposte.net>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox