Re: Convert "epoch" to timestamp

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jeff Eckermann <jeff_eckermann(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Convert "epoch" to timestamp
Date: 2002-04-23 15:04:55
Message-ID: 20464.1019574295@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Jeff Eckermann <jeff_eckermann(at)yahoo(dot)com> writes:
> According to posts in the archives, the following used
> to work:

> jeff=# select timestamp(1019571752);
> ERROR: TIMESTAMP(1019571752) WITH TIME ZONE precision
> must be between 0 and 13
> jeff=#

Still works if you quote it:

regression=# select "timestamp"(1019571752);
timestamp
---------------------
2002-04-23 10:22:32
(1 row)

regression=# select "timestamptz"(1019571752);
timestamptz
------------------------
2002-04-23 10:22:32-04
(1 row)

However, the cast to abstime may be preferable, since Thomas is unlikely
to keep fiddling with the syntax and semantics of that type ;-) ;-).

Eventually there should be an exact converse of the extract(epoch)
functionality, rather than these various kluges relying on
abstime-to-integer equivalence.

We'll probably start thinking about removing abstime when Unix systems
start to migrate away from 32-bit time_t, which one hopes will happen
well before the year 2038. So eventually something's got to be done.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alejandro Fernandez 2002-04-23 15:12:30 Connections per second?
Previous Message Thomas Lockhart 2002-04-23 15:04:20 Re: Convert "epoch" to timestamp