Re: convert a bigint into a timestamp

Lists: pgsql-sql
From: marc sturm <marc_wea(at)yahoo(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: convert a bigint into a timestamp
Date: 2002-07-25 00:48:19
Message-ID: 20020725004819.8083.qmail@web20705.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql

Hello,

Does anyone know how to convert a bigint into a date
or timestamp in a SQL query.
Thanks a lot.

Marc

__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com


From: Richard Huxton <dev(at)archonet(dot)com>
To: marc sturm <marc_wea(at)yahoo(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: convert a bigint into a timestamp
Date: 2002-07-25 10:34:16
Message-ID: 200207251134.16658.dev@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql

On Thursday 25 Jul 2002 1:48 am, marc sturm wrote:
> Hello,
>
> Does anyone know how to convert a bigint into a date
> or timestamp in a SQL query.
> Thanks a lot.

The problem is that there is no cast from bigint=>interval directly AFAICT, so
go via text.

richardh=> select extract(epoch from now());
date_part
------------------
1027593096.67471
(1 row)

richardh=> select '1970-01-01 00:00:00 GMT'::timestamp +
((1027593096::bigint)::text)::interval;
?column?
------------------------
2002-07-25 11:31:36+01

In your case you'd replace (1027593096::bigint) with the name of your column.

HTH

- Richard Huxton