format_datetime() in Kusto for datetime with minutes and seconds as 00
format_datetime() in Kusto for datetime with minutes and secounds as 00
azure data explorer documentation 中有很多受支持的格式,但不是我要找的格式。
我需要的是像"yyyy-MM-dd HH"
这样格式化日期时间,将分和秒设置为0
输入日期时间
2020-04-21T17:44:27.6825985Z
预期结果
2020-04-21 17:00:00
嗯,如果你总是只想让其余的都为0,你可以只使用字符串连接吗?
let d = datetime(2020-04-21T17:44:27.6825985Z);
print strcat(format_datetime(d, "yyyy-MM-dd HH"), ":00:00")
上面的代码会给你
的结果
2020-04-21 17:00:00
可以使用bin()
向下取整到小时,如果还需要去掉小于秒的datetime部分,可以使用substring()
(或format_datetime()
) .例如:
print d = datetime(2020-04-21T17:44:27.6825985Z)
| extend h = bin(d, 1h)
| extend h2 = substring(h, 0, 19)
azure data explorer documentation 中有很多受支持的格式,但不是我要找的格式。
我需要的是像"yyyy-MM-dd HH"
这样格式化日期时间,将分和秒设置为0
输入日期时间
2020-04-21T17:44:27.6825985Z
预期结果
2020-04-21 17:00:00
嗯,如果你总是只想让其余的都为0,你可以只使用字符串连接吗?
let d = datetime(2020-04-21T17:44:27.6825985Z);
print strcat(format_datetime(d, "yyyy-MM-dd HH"), ":00:00")
上面的代码会给你
的结果2020-04-21 17:00:00
可以使用bin()
向下取整到小时,如果还需要去掉小于秒的datetime部分,可以使用substring()
(或format_datetime()
) .例如:
print d = datetime(2020-04-21T17:44:27.6825985Z)
| extend h = bin(d, 1h)
| extend h2 = substring(h, 0, 19)