problem with unixtime conversion

Started by Nathan Sudermanabout 23 years ago3 messagesgeneral
Jump to latest
#1Nathan Suderman
nathan@pollstar.com

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?

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Nathan Suderman (#1)
Re: problem with unixtime conversion

"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

#3Ben
bench@silentmedia.com
In reply to: Nathan Suderman (#1)
Re: problem with unixtime conversion

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