"Morten W. Petersen" <morten@src.no> writes:
> Is there such a function (couldn't find it)
You can cast an integer representing Unix timestamp directly to abstime,
and thence to any other datetime type you want:
regression=# select abstime(962057134);
abstime
------------------------
2000-06-26 18:05:34-04
(1 row)
To go the other way, you can cast to abstime and then int4, or you can
use date_part('epoch',...):
regression=# select int4(abstime('2000-06-26 18:05:34-04'::timestamp));
int4
-----------
962057134
(1 row)
regression=# select date_part('epoch','2000-06-26 18:05:34-04'::timestamp);
date_part
-----------
962057134
(1 row)
This works in 7.0, not sure about earlier releases.
regards, tom lane