Search Postgresql Archives

Re: timestamp without timezone to have timezone

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On Sun, Nov 6, 2016 at 9:11 AM, Benjamin Adams <benjamindadams@xxxxxxxxx> 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.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux