ADF:如何将DateTime列(AM/PM)转换为UTC格式?
我有一个列,其中时间戳为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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您获得新添加列的零值的原因是因为您在
totimestamp()
函数中指定的格式不正确。以下是我用来重现此问题的示例数据。date
列此处是类型字符串
。在数据流中使用
派生列
以创建timestamp
类型的新日期列,写totimestamp(日期,'mm/ DD/YYYY HH:MM:SS a','utc')
表达式作为此新列的值。在这里,日期是您要转换为新日期列的列,mm/dd/yyyy HH:MM:SS A
是date> date
column> column中的值的格式(a
表示AM/PM)。您还可以传递时区值,例如utc
,gmt
等。它是可选。以下是结果的样子,并具有
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. Thedate
column here is of typeString
.While using
Derived column
in the dataflow to create a new date column oftimestamp
type, writetoTimestamp(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 andMM/dd/yyyy hh:mm:ss a
is the format of the values indate
column (a
represents the AM/PM). You can also pass time zone value likeUTC
,GMT
etc. which is optional.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.