Thread: problem with unixtime conversion

problem with unixtime conversion

From
"Nathan Suderman"
Date:
does anyone know why I get the following error?  running postgres 7.3.1
 

test=> select date(date_part('epoch','now'::date)::int);
ERROR:  Bad date external representation '1042502400'
 
better yet does anyone have a better way to convert unixtime back to standard readable time?

Re: problem with unixtime conversion

From
Tom Lane
Date:
"Nathan Suderman" <nathan@pollstar.com> writes:
> test=> select date(date_part('epoch','now'::date)::int);
> ERROR:  Bad date external representation '1042502400'

I think your code was relying on the int->abstime coercion, which was
implicitly invokable before 7.3, but now has to be specified explicitly.

regression=# select date(date_part('epoch','now'::date)::int::abstime);
    date
------------
 2003-01-13
(1 row)


            regards, tom lane

Re: problem with unixtime conversion

From
Ben
Date:
On Tue, 14 Jan 2003, Nathan Suderman wrote:

> better yet does anyone have a better way to convert unixtime back to
> standard readable time?


some_unixtime_field::int4::abstime