gpt4 book ai didi

azure - ADF : How to Convert a datetime column (AM/PM) to UTC format?

转载 作者:行者123 更新时间:2023-12-03 05:20:44 25 4
gpt4 key购买 nike

我有一个列,其中时间戳为 5/23/2022 8:45:34 PM。我想创建一个新列,其数据与旧列相同,但采用 UTC 格式“yyyy-MM-dd HH:mm:ss”,并且此新日期时间格式比 UTC (UTC-7) 晚 7 小时

我尝试在 Azure 数据工厂派生列中使用 toTimestamp 在转换为 UTC 之前进行操作,但总是失败。

toTimestamp(column_name,'yyyy-MM-dd HH:mm:SS')

但它不起作用,结果总是 NULL。

任何人都可以帮助将数据转换为 UTC 吗?

最佳答案

您在新添加的列中获取空值的原因是您在 toTimestamp() 函数中指定的格式不正确。以下是我用来重现此问题的示例数据。这里的date列的类型是String

enter image description here

在数据流中使用派生列创建timestamp类型的新日期列时,写入toTimestamp(date, 'MM/dd/yyyy hh: mm:ss a', 'UTC') 表达式作为此新列的值。此处,日期是要转换为新日期列的列,MM/dd/yyyy hh:mm:ss adate 列中值的格式( a 代表 AM/PM)。您还可以传递时区值,例如 UTCGMT 等。这是可选

enter image description here

以下是结果的样子,其中有一个 timestamp 类型的新列。您可以使用生成的数据在数据流中执行进一步的转换。

enter image description here

关于azure - ADF : How to Convert a datetime column (AM/PM) to UTC format?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72598588/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com