Re: EPOCH TIMESTAMP Conversion Problem

From: Michael Glaesemann <grzm(at)seespotcode(dot)net>
To: Louis-David Mitterrand <vindex+lists-pgsql-sql(at)apartia(dot)org>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: EPOCH TIMESTAMP Conversion Problem
Date: 2008-01-01 19:32:25
Message-ID: B0EE8783-066E-4A79-9E86-C3AD6411E45B@seespotcode.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


On Jan 1, 2008, at 9:28 , Louis-David Mitterrand wrote:

> On Wed, Nov 07, 2007 at 10:35:08AM -0500, Tom Lane wrote:
>> "Amitanand Chikorde" <amit99rs(at)gmail(dot)com> writes:
>>> I want to convert MAX(mydate) from myTable to Epoch.
>>
>> Do you mean
>> SELECT EXTRACT(EPOCH FROM MAX(mydate)) FROM myTable
>
> Is using casts for the same purpose deprecated?
>
> SELECT current_date::timestamp::abstime::int4;

EXTRACT is SQL-standard syntax which appeals to some people. The ::
casting syntax is a Postgres extension. And from the docs:

http://www.postgresql.org/docs/8.2/static/datatype-datetime.html

> The types abstime and reltime are lower precision types which are
> used internally. You are discouraged from using these types in new
> applications and are encouraged to move any old ones over when
> appropriate. Any or all of these internal types might disappear in
> a future release.

Michael Glaesemann
grzm seespotcode net

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Fernando Hevia 2008-01-02 18:43:42 PG is in different timezone than the OS
Previous Message Tom Lane 2008-01-01 19:03:48 Re: EPOCH TIMESTAMP Conversion Problem