雪花日期格式转换问题
我必须格式化几种CSV的几种不同时间格式。现在,我在以下时间戳上有一个问题:
31 Mai 2022 22:41:19 UTC
我尝试使用
SELECT to_timestamp('31 mai 2022 23:22:01 UTC', 'DD MON YYYY HH24:MI:SS UTC')
此操作,因为MAI的名称不被认为是一个月,并带有以下错误消息,
Can't parse '31 mai 2022 23:22:01 UTC' as timestamp with format 'DD MON YYYY HH24:MI:SS UTC'
因此当我将Mai更改为MAI到MAI时,它的工作正常,
SELECT to_timestamp('31 may 2022 23:22:01 UTC', 'DD MON YYYY HH24:MI:SS UTC')
所以我的建议是使用替换功能将其设置为英文表达式。但这不是很优雅,我还需要在3月,10月和12月的几个月内实施它。
我是否可以使用不同的模式,所以雪花认识到这是德国的表达('dd mon yyyy hh24:mi:mi:ss utc')吗?
我已经试图将会话时区更改为“欧洲/柏林”,但这并没有解决。
I have to format several different time formats from several CSVs. Now I have a Problem with following timestamp:
31 Mai 2022 22:41:19 UTC
I tried with
SELECT to_timestamp('31 mai 2022 23:22:01 UTC', 'DD MON YYYY HH24:MI:SS UTC')
This is not working out because the name of mai is not recognized as a month, with following error message
Can't parse '31 mai 2022 23:22:01 UTC' as timestamp with format 'DD MON YYYY HH24:MI:SS UTC'
So when I change mai to may it's working fine
SELECT to_timestamp('31 may 2022 23:22:01 UTC', 'DD MON YYYY HH24:MI:SS UTC')
So my suggestion would be to use REPLACE function to set it to the english expression. But it's not very elegant and I would need to implement it for the months of March, Oct and Dec as well.
Is there maybe a different pattern I can use, so Snowflake recognizes that it is a german expression ('DD MON YYYY HH24:MI:SS UTC')?
I already tried to change my SESSION timezone to 'Europe/Berlin' but this was not working out.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
需要修复时间戳,日期等的输入和输出格式。不允许自定义输入。
请参阅这些链接以获取更多详细信息。它也有示例。
https://docs.snowflake.com/en/user-guide/date time-input-of-xutput.html#session-parameters-parameters-for-dates-for-dates-times-times-and-and-times-and-timestamps
<一个href =“ https://docs.snowflake.com/en/user-guide/date time-input-xutput.html#about-the-format-specifiers-in-in-this Section” rel =“ nofollow” noreferrer“> https://docs.snowflake.com/en/user-guide/date time-input-xutput.html#about-the-format-specifiers-in-in-this-Section
< a href =“ https://docs.snowflake.com/en/sql-reference/functions/to_timestamp.html” rel =“ nofollow noreferrer”> https://docs.snowflake.com/en/sql-reference/functions/to_timestamp.html
The input and output format for the Timestamp, date, etc needs to be fixed. custom input is not allowed.
Please refer to these links for more details. It has examples as well.
https://docs.snowflake.com/en/user-guide/date-time-input-output.html#session-parameters-for-dates-times-and-timestamps
https://docs.snowflake.com/en/user-guide/date-time-input-output.html#about-the-format-specifiers-in-this-section
https://docs.snowflake.com/en/sql-reference/functions/to_timestamp.html
甚至德语雪花文档您将需要遵循BDR的建议来重新重建值。
Even the German Snowflake documentation reflects English month names so it appear you will need to follow BdR's suggestion to remap the values.