pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jasen Betts <jasen@xnet.co.nz>
To: pgsql-sql@postgresql.org
Subject: Re: converting big int to date
Date: 26 Mar 2011 10:04:43 GMT
Message-ID: <imkdnr$duk$5@reversiblemaps.ath.cx> (raw)
References: <AANLkTimNMmCuHLgwPHppz4iKy8QUB8WcJi3zZ-yW19HW@mail.gmail.com>

On 2011-03-23, Sree <mail2mail@gmail.com> wrote:
> --90e6ba2123fbe15f02049f2ccf73
> Content-Type: text/plain; charset=ISO-8859-1
>
> How can i convert bigint to date format.
>
> bigint=616962528000000000


that's got the right number of zeros to
be a date expressed as microseconds since epoch

in which case the magic spell is

 select 'epoch'::timestamptz 
           + '1s'::interval 
               * (616962528000000000::bigint /1000000000.0);
      
 gives me a date in 1989
 
if it's some from a microsoft inspored system instead of AT&T inspired
you might need to add '10 years'::interval to the result.

-- 
⚂⚃ 100% natural




view thread (4+ messages)  latest in thread

Message-ID: <imkdnr$duk$5@reversiblemaps.ath.cx>
Permalink:  ../imkdnr$duk$5@reversiblemaps.ath.cx/
Also on:    postgresql.org/message-id/imkdnr$duk$5@reversiblemaps.ath.cx

 · 

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: jasen@xnet.co.nz
  Subject: Re: converting big int to date
  In-Reply-To: <imkdnr$duk$5@reversiblemaps.ath.cx>

* 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