pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: marc sturm <marc_wea@yahoo.com>
To: pgsql-sql@postgresql.org
Subject: Re: convert a bigint into a timestamp
Date: Thu, 25 Jul 2002 11:34:16 +0100
Message-ID: <200207251134.16658.dev@archonet.com> (raw)
In-Reply-To: <20020725004819.8083.qmail@web20705.mail.yahoo.com>
References: <20020725004819.8083.qmail@web20705.mail.yahoo.com>

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



view thread (2+ messages)

Message-ID: <200207251134.16658.dev@archonet.com>
Permalink:  ../200207251134.16658.dev@archonet.com/
Also on:    postgresql.org/message-id/200207251134.16658.dev@archonet.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: dev@archonet.com, marc_wea@yahoo.com
  Subject: Re: convert a bigint into a timestamp
  In-Reply-To: <200207251134.16658.dev@archonet.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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