Reputation: 1774
We are loading data from Hana to Snowflake. In Hana, we have time stored in different formats like CET, UTC+3, UTC+4, BRAZIL,AUSACT etc. In hana, we have a function that can convert the timestamp into these various time zones. How do we do it in Snowflake?
Upvotes: 0
Views: 382
Reputation: 1774
The process I followed is as below
CREATE OR REPLACE TABLE HANA_SF_CONVERT(HANA_FORMAT VARCHAR,SF_FORMAT VARCHAR);
insert into HANA_SF_CONVERT(HANA_FORMAT,SF_FORMAT) VALUES('CET','Africa/Ceuta');
insert into HANA_SF_CONVERT(HANA_FORMAT,SF_FORMAT) VALUES('AUSACT','Australia/ACT');
CREATE OR REPLACE function hana_sf_convert(hana_fmt string,sf_tz string,date_val timestamp)
returns timestamp
as
$$
select convert_timezone((select SF_FORMAT from
HANA_SF_CONVERT where HANA_FORMAT = hana_fmt ),sf_tz ,date_val )
$$
;
Finally, can query as below
select hana_sf_convert('CET','America/Los_Angeles',date_val::timestamp_ntz) as time, date_val from <table>;
Upvotes: 1
Reputation: 26068
Greg nailed this.
So that answers the question if there is built it functions.
Can you build your own function that uses SQL or JavaScript to covert from the reference/name space you have, to values Snowflake supports sure.
Upvotes: 0