将varchar转换为Snowflake中的timestamp

huangapple go评论59阅读模式
英文:

Convert varchar to timestamp in snowflake

问题

我有一张Snowflake表格中有几列,其中存储的日期时间格式为2022-04-27T10:38:21.3000000+1000,类型为VARCHAR。

我想将其转换为正确的Timestamp对象。我尝试了以下方法:

TO_TIMESTAMP('2022-04-27T10:38:21.3000000+1000')

但它报错说无法识别格式。请问有什么建议吗?

英文:

I have few columns in a snowflake table which has date time stored in the format
2022-04-27T10:38:21.3000000+1000 as VARCHAR.

I would want to convert it as proper Timestamp object. I tried using below

TO_TIMESTAMP('2022-04-27T10:38:21.3000000+1000')

It is throwing error as not recognized format. Any suggestion please?

答案1

得分: 1

你需要按照文档来指定日期/时间字符串的输入格式。

尝试这样做:

SELECT TO_TIMESTAMP('2022-04-27T10:38:21.3000000+1000', 'YYYY-MM-DDTHH:MI:SS.FFTZHTZM');
英文:

You need to specify the input format for your date/time string as per the doc

Try this:

SELECT TO_TIMESTAMP('2022-04-27T10:38:21.3000000+1000', 'YYYY-MM-DDTHH:MI:SS.FFTZHTZM');

huangapple
  • 本文由 发表于 2023年7月13日 21:54:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/76680188.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定