Timestamp Shifts when calling to_timestamp(extract (epoch from timestamp))

From: Robert Burgholzer <rburghol(at)vt(dot)edu>
To: "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
Subject: Timestamp Shifts when calling to_timestamp(extract (epoch from timestamp))
Date: 2015-05-12 23:49:47
Message-ID: CACT-NGKK1vQxb+UDwj_Ji6co+COf-6P6nm7YAME+e4L4xvbJuA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Ok, thanks a ton - I get it! (i think) let me try this out (maybe you said
this all along:

- an epoch is by definition in GMT - it can't be otherwise
- an epoch is translated from its source TZ if TZ is specified, otherwise
it's assumed GMT
- to_timestamp translates into the local TZ Always.
- therefore, the only time TStamp->Epoch->Tstamp results in identity is
when the TZ of the original Tstamp is in the TZ specified in
postgresql.conf?

The "always" part of to_timestamp seems a tad limiting, but I dig, "+
interval" is my friend.

Thanks!

On Tuesday, May 12, 2015, Scott Ribe <scott_ribe(at)elevated-dev(dot)com
<javascript:_e(%7B%7D,'cvml','scott_ribe(at)elevated-dev(dot)com');>> wrote:

> On May 12, 2015, at 12:07 PM, Robert Burgholzer <rburghol(at)vt(dot)edu> wrote:
> >
> > But if nothing else, it still seems to me that "to_timestamp" and
> "extract(epoch)" are making different assumptions when TZ is not known.
>
> Not really, it’s just that by default the result of to_timestamp is
> *displayed* in your local zone.
>
> --
> Scott Ribe
> scott_ribe(at)elevated-dev(dot)com
> http://www.elevated-dev.com/
> https://www.linkedin.com/in/scottribe/
> (303) 722-0567 voice
>
>
>
>
>
>

--
--
Robert W. Burgholzer
'Making the simple complicated is commonplace; making the complicated
simple, awesomely simple, that's creativity.' - Charles Mingus
Athletics: http://athleticalgorithm.wordpress.com/
Science: http://robertwb.wordpress.com/
Wine: http://reesvineyard.wordpress.com/

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Scott Ribe 2015-05-12 23:58:35 Re: Timestamp Shifts when calling to_timestamp(extract (epoch from timestamp))
Previous Message Scott Ribe 2015-05-12 18:31:25 Re: Timestamp Shifts when calling to_timestamp(extract (epoch from timestamp))