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.