SQL – From timestamptz A to timestamptz B

For PostgreSQL (tested on 9.4)

CREATE TABLE tests(id serial not null, created_on timestamptz);
INSERT INTO tests (created_on) VALUES (now());
2016-02-16 19:26:13.823126-05

I guess you have configured your timezone in your postgresql.conf file. I have for information ‘America/Toronto’.

SELECT created_on  AT TIME ZONE ‘Europe/Paris’ FROM tests;
2016-02-17 01:26:13.823126

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.