pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
convert a bigint into a timestamp
2+ messages / 2 participants
[nested] [flat]

* convert a bigint into a timestamp
@ 2002-07-25 00:48  marc sturm <marc_wea@yahoo.com>
  0 siblings, 1 reply; 2+ messages in thread

From: marc sturm @ 2002-07-25 00:48 UTC (permalink / raw)
  To: 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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: convert a bigint into a timestamp
@ 2002-07-25 10:34  Richard Huxton <dev@archonet.com>
  parent: marc sturm <marc_wea@yahoo.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Richard Huxton @ 2002-07-25 10:34 UTC (permalink / raw)
  To: marc sturm <marc_wea@yahoo.com>; 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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2002-07-25 10:34 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-07-25 00:48 convert a bigint into a timestamp marc sturm <marc_wea@yahoo.com>
2002-07-25 10:34 ` Richard Huxton <dev@archonet.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox