简体   繁体   English

如何将 Snowflake 中的数组或字符串转换为 Timestamp_NTZ

[英]How to Convert Array or String in Snowflake to Timestamp_NTZ

I currently have some incoming datestamps as from outside datasource, but am struggling to define them in a table through my Snowflake Tables.我目前有一些来自外部数据源的传入日期戳,但我正在努力通过我的雪花表在表中定义它们。

The column is formatted as such: {"type":"TEXT","length":12,"byteLength":48,"nullable":true,"fixed":false}该列的格式如下: {"type":"TEXT","length":12,"byteLength":48,"nullable":true,"fixed":false}

The only current workaround I have is this convoluted code.我目前唯一的解决方法是这个复杂的代码。

SELECT timestamp_ntz_from_parts(
            GET(strtok_to_array(CONCAT('20',array_to_string(
                             regexp_substr_all('220530161501', '[[:digit:]][[:digit:]]', 1, 1),',')),','),0)::DOUBLE,
                               .......);

Any suggestions to convert string to integer for timestamp?将字符串转换为 integer 以获得时间戳的任何建议?

Assuming the format of input 'YYMMDDHH24MISS' and first 22 stands for 2022 :假设输入 'YYMMDDHH24MISS' 的格式和前22代表2022

SELECT TRY_TO_TIMESTAMP_NTZ( '220530161501', 'YYMMDDHH24MISS');

Output: Output:

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM