Re: timestamp without timezone to have timezone - Mailing list pgsql-general

From Melvin Davidson
Subject Re: timestamp without timezone to have timezone
Date
Msg-id CANu8Fixi+hJ_5H=Km5s8MMR76M1tNcqXTJWNHRFktfo+4OQRLw@mail.gmail.com
Whole thread Raw
In response to timestamp without timezone to have timezone  (Benjamin Adams <benjamindadams@gmail.com>)
Responses Re: timestamp without timezone to have timezone
List pgsql-general


On Sun, Nov 6, 2016 at 9:11 AM, Benjamin Adams <benjamindadams@gmail.com> wrote:
I have a server that has a column timestamp without timezone.

Is the time still saved?
if I select column with timestamp it will show server timestamp with timezone.

But If I move the data from EST to Central will the timestamp with timezone be correct?
Or will it just not make the adjustment?

Thanks
Ben

>But If I move the data from EST to Central will the timestamp with timezone be correct?

The correct way to do that is to use the  AT TIME ZONE function.

https://www.postgresql.org/docs/9.4/static/functions-datetime.html#FUNCTIONS-DATETIME-ZONECONVERT

eg:
postgres=> SELECT TIMESTAMP '2001-02-16 20:38:40' AT TIME ZONE 'EST' as Eastern,
postgres-> TIMESTAMP '2001-02-16 20:38:40' AT TIME ZONE 'CST' as Central,
postgres-> TIMESTAMP '2001-02-16 20:38:40' AT TIME ZONE 'MST' as Mountain,
postgres-> TIMESTAMP '2001-02-16 20:38:40' AT TIME ZONE 'PST' as Pacific;
eastern | central | mountain | pacific
------------------------+------------------------+------------------------+------------------------
2001-02-16 20:38:40-05 | 2001-02-16 21:38:40-05 | 2001-02-16 22:38:40-05 | 2001-02-16 23:38:40-05
(1 row)
--
Melvin Davidson
I reserve the right to fantasize.  Whether or not you
wish to share my fantasy is entirely up to you.

pgsql-general by date:

Previous
From: Benjamin Adams
Date:
Subject: timestamp without timezone to have timezone
Next
From: Adrian Klaver
Date:
Subject: Re: timestamp without timezone to have timezone