【发布时间】:2018-01-24 05:57:57
【问题描述】:
流解析的输入是IoT hub,它会收到JSON这样的消息。
数据:
[
{
"deviceId": "testing",
"id": "b8db8f582c474225b90b75dfed2e9c63",
"username": "testing",
"localtime": "24/01/2018 11:31:24",
"b": 240,
"e": 357,
"AC": 0,
"FM": 0,
"UC": 0,
"DL": 0,
"DS": 0,
"DP": 0,
"DR": 0,
"LB": 120,
"ASTV": 73,
"MSTV": 0.5,
"ALTV": 43
}
]
在Azure Stream Analytics 查询中,我使用CAST 函数将本地时间从字符串转换为日期时间,但它失败了。不允许使用CONVERT 功能。
SELECT
id as id,
deviceId as deviceId,
username as username,
cast(localtime as datetime) as localtime,
AC as AC, FM as FM, UC as UC,
DL as DL, DS as DS, DP as DP,
LB as LB, ASTV as ASTV, MSTV as MSTV
FROM
iot
无法将值“24/01/2018 12:58:23”转换为表达式“cast (localtime as datetime)”中的类型“datetime”
【问题讨论】:
-
你在尝试我更新的答案吗?有什么问题,写在cmets。
-
试试我更新的答案,希望它现在可以工作......
-
SUBSTRING 是受支持的
function。
标签: azure tsql datetime azure-stream-analytics