TIMESTAMP query depending on vertica server location
Hi
We have a table storing a raw TIMESTAMP value (without any extra timezone information. We would like to query that column assuming UTC timestamp and returning it at UTC. When performing such a query vertica applies a number of implicit conversions, I believe based on the location of the server which in our case is running at 'Europe/London'. We managed to construct a query that returns what we want but it seems a bit clunky:
select ts at time zone 'Europe/London' at time zone 'UTC' as ts from MyTable where ts > '2019-04-24 11:00:07.353 UTC' and ts < '2019-04-24 11:00:07.477 UTC';
Is there a way to avoid double timestamp conversion? If not, is there at least a way to embed server timezone in the query itself rather than hardcoding 'Europe/London'?
Thank you
Best Answer
-
SruthiA Administrator
you can set your session timezone using SET TIMEZONE command in vertica.
Vertica uses the TZ environment variable on each node, if it has been set, for the default current time zone. Otherwise, Vertica uses the operating system time zone. Please review the below links for more information.
https://www.vertica.com/docs/9.2.x/HTML/Content/Authoring/InstallationGuide/AppendixTimeZones/UsingTimeZonesWithVertica.htm5