Vertica converts Local time to GMT time, verticagmt

Source: Internet
Author: User
Tags gmt time zone time zones

Vertica converts Local time to GMT time, verticagmt

When using Vertica databases, the program collects data from clusters in different time zones and writes it to the same table. Then we need to display the data according to the GMT time. In this case, we can use Vertica to provide the time zone conversion function.

First, let's take a look at the default TimeZone of Vertica.

SHOW TIMEZONE;
Assume that the default TimeZone of Vertica is "Asia/Shanghai"
SET TIMEZONE TO 'Asia/Shanghai';
Assume that there is a table, the TS column stores the timestamp, And the TZ column stores the time zone, as shown below:

CREATE TABLE T (TS TIMESTAMP, TZ VARCHAR(32));
Then, the two data types are created using the America/New_York and Asia/Shanghai time zones respectively.

INSERT INTO T VALUES(TIMESTAMP'2014-11-11 00:00:00', 'America/New_York');INSERT INTO T VALUES(TIMESTAMP'2014-11-11 00:00:00', 'Asia/Shanghai');
At this time, you can use the following SQL to convert the time of each Local time zone to the GMT time zone.

SELECT    (TS || ' ' || TZ)::TIMESTAMP AS 'LOCAL TIME',     (TS || ' ' || TZ)::TIMESTAMP WITH TIME ZONE AT TIME ZONE 'GMT' AS 'GMT TIME'FROM T;      LOCAL TIME      |      GMT TIME---------------------+--------------------- 2014-11-11 13:00:00 | 2014-11-11 05:00:00 2014-11-11 00:00:00 | 2014-11-10 16:00:00

Original article: Vertica converts Local time to GMT time

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.