Re: converting PostgreSQ- timestamp to UNIX-timestamp ? - Mailing list pgsql-general

From Tom Lane
Subject Re: converting PostgreSQ- timestamp to UNIX-timestamp ?
Date
Msg-id 4339.1063823156@sss.pgh.pa.us
Whole thread Raw
In response to converting PostgreSQ- timestamp to UNIX-timestamp ?  ("Cornelia Boenigk" <poppcorn@cornelia-boenigk.de>)
List pgsql-general
"Cornelia Boenigk" <poppcorn@cornelia-boenigk.de> writes:
> To convert PostgreSQL timestmp to UNIX timestamp I use
> select ((today::abstime)::int4) from table ...
> In the documentation there is a notice that abstime shouldn't be used.
> Is there another way to convert?

"SELECT EXTRACT(EPOCH FROM timestamp)" is the recommended way to do it.

> Also I tried
> select timetz_hash(today) from table ..
> and got negative values for some timestamps. Does anybody know why?

Why not?  If the hash function didn't use all 32 available bits, I'd
think it faulty ...

            regards, tom lane

pgsql-general by date:

Previous
From: jason dang
Date:
Subject: Bug while installing in AIX 5.1
Next
From: "Daniel Schuchardt"
Date:
Subject: Re: psql and blob