Re: Cast: timestamp to integer - Mailing list pgsql-general

From Stephan Szabo
Subject Re: Cast: timestamp to integer
Date
Msg-id 20030612110321.R31475-100000@megazone23.bigpanda.com
Whole thread Raw
In response to Cast: timestamp to integer  (Michal Durys <joe@anime.com.pl>)
List pgsql-general
On Thu, 12 Jun 2003, Michal Durys wrote:

> Hello,
>
> I hope it's not a question for psql-novice. ;-)
>
> I'd like to convert timestamp and date fields to intergers.
> Unfortunately cast() says it's impossible:
>
> ERROR: Cannot cast type date to integer
> ERROR: Cannot cast type timestamp without time zone to integer
>
> I'm quite sure it should be possible somehow. After all timestamp is
> (AFAIR) number of seconds counted from 1970.

I believe EXTRACT has an "epoch" unit that is seconds from 1970 as a
double which you can cast to an int.


pgsql-general by date:

Previous
From: "Ian Harding"
Date:
Subject: Re: Postgres performance comments from a MySQL user
Next
From: Bruno Wolff III
Date:
Subject: Re: LAST_INSERT_ID equivalent