ADF:如何将DateTime列(AM/PM)转换为UTC格式?

发布于 2025-02-07 06:54:05 字数 334 浏览 1 评论 0原文

我有一个列,其中时间戳为5/23/2022 8:45:34 PM。我想创建一个具有与旧列相同数据的新列,但是以UTC格式“ Yyyy-MM-DD HH:MM:SS”,此新的DateTime格式落后于UTC(UTC-7),

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

totimestamp(column_name,'yyyy-mm-dd HH:mm:ss')

但它不起作用,结果始终为无效。

谁能帮助此数据转换为UTC?

I have a column where timestamp is 5/23/2022 8:45:34 PM. I want to create a new column with same data as old column but in UTC format 'yyyy-MM-dd HH:mm:ss' and this new datetime format is 7 hours behind UTC (UTC-7)

I tried doing in azure data factory derived column using toTimestamp before it converts to UTC but it always fail.

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

but it did not work and the result always NULL.

Can anyone help this data conversion to UTC ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

倾城泪 2025-02-14 06:54:05

您获得新添加列的零值的原因是因为您在totimestamp()函数中指定的格式不正确。以下是我用来重现此问题的示例数据。 date列此处是类型字符串

在数据流中使用派生列以创建timestamp类型的新日期列,写totimestamp(日期,'mm/ DD/YYYY HH:MM:SS a','utc')表达式作为此新列的值。在这里,日期是您要转换为新日期列的列,mm/dd/yyyy HH:MM:SS Adate> date column> column中的值的格式( a表示AM/PM)。您还可以传递时区值,例如utcgmt等。它是可选

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

The reason you are getting null values for the newly added columns is because the format you specified in the toTimestamp() function is incorrect. The following is the sample data that I used to reproduce this issue. The date column here is of type String.

enter image description here

While using Derived column in the dataflow to create a new date column of timestamp type, write toTimestamp(date, 'MM/dd/yyyy hh:mm:ss a', 'UTC') expression as the value for this new column. Here, date is the column you want to convert to new date column and MM/dd/yyyy hh:mm:ss a is the format of the values in date column (a represents the AM/PM). You can also pass time zone value like UTC, GMT etc. which is optional.

enter image description here

The following is what the result looks like, with a new column of timestamp type. You can use this resulting data to perform further conversions in dataflow.

enter image description here

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