Thread: more on timestamps

more on timestamps

From
Gregory Seidman
Date:
Okay, I've come to the conclusion that I can manipulate timestamps in
almost all the ways I'd like to. The only issue I have is insertion. I'd
like to be able to insert an epoch-based value directly into a timestamp
field. It seems like I should be able to do that, but:

timemanage=> create table testing ( field timestamp with time zone);
CREATE
timemanage=> insert into testing values(1021780800);
ERROR:  column "field" is of type 'timestamp with time zone' but expression is of type 'integer'
        You will need to rewrite or cast the expression

According to http://www.postgresql.org/idocs/index.php?typeconv-query.html
it looks like the existence of timestamptz(int) (or maybe it's double
precision...) should allow the insertion, but it doesn't. Is there any way
to get PostgreSQL to automatically coerce an int (or double) to a
timestamptz on insertion?

--Greg