Re: converting big int to date

From: Jasen Betts <jasen(at)xnet(dot)co(dot)nz>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: converting big int to date
Date: 2011-03-26 10:04:43
Message-ID: imkdnr$duk$5@reversiblemaps.ath.cx
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On 2011-03-23, Sree <mail2mail(at)gmail(dot)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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Jasen Betts 2011-03-27 08:32:52 Re: converting big int to date
Previous Message Vibhor Kumar 2011-03-24 16:30:48 Re: converting big int to date