Re: converting PostgreSQ- timestamp to UNIX-timestamp ?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Cornelia Boenigk" <poppcorn(at)cornelia-boenigk(dot)de>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: converting PostgreSQ- timestamp to UNIX-timestamp ?
Date: 2003-09-17 18:25:56
Message-ID: 4339.1063823156@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Cornelia Boenigk" <poppcorn(at)cornelia-boenigk(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Daniel Schuchardt 2003-09-17 18:37:47 Re: psql and blob
Previous Message jason dang 2003-09-17 18:11:07 Bug while installing in AIX 5.1