雪花日期格式转换问题

发布于 2025-02-12 13:14:38 字数 683 浏览 0 评论 0原文

我必须格式化几种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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

陈甜 2025-02-19 13:14:39

需要修复时间戳,日期等的输入和输出格式。不允许自定义输入。

请参阅这些链接以获取更多详细信息。它也有示例。

  1. 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

  2. <一个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

  3. < 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

冬天的雪花 2025-02-19 13:14:39

甚至德语雪花文档您将需要遵循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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文