Re: How to convert a UnixTimestamp to a PostgreSQL date without using ::abstime ?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Bruno BAGUETTE" <pgsql-ml(at)baguette(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How to convert a UnixTimestamp to a PostgreSQL date without using ::abstime ?
Date: 2003-09-10 03:41:05
Message-ID: 26997.1063165265@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Bruno BAGUETTE" <pgsql-ml(at)baguette(dot)net> writes:
> I'm looking for a way to convert a unix timestamp to a PostgreSQL date
> without using ::abstime which seems to be deprecated.

abstime is not yet deprecated in my mind, precisely because it's still
the easiest way to do the reverse of "extract(epoch from timestamp)".
The cleanest alternative I know of is

select 'epoch'::timestamptz + (unixtimestamphere) * '1 sec'::interval;

but this still leaves an unsatisfied feeling. Sooner or later we'll
probably invent an explicit function to do this conversion.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alex Martinoff 2003-09-10 04:02:21 Constructing column from different individual fields in same row.
Previous Message Marc G. Fournier 2003-09-10 03:30:49 Re: State of Beta 2