gpt4 book ai didi

azure - 如何在azure kusto查询中将todatetime转换为秒

转载 作者:行者123 更新时间:2023-12-02 23:57:54 28 4
gpt4 key购买 nike

例如,我有一个查询,

workspace("someanalytics").somecheck
| where someProperties_s contains "something"
| project someProperties_s , TimeGenerated
| extend somethingAB = parse_json(someProperties_s)
| extend somethingabc= somethingAB.something
| project TimeGenerated, tostring(somethingabc)
| order by TimeGenerated, somethingabc desc
| extend somethingabcchart = somethingabc
| parse somethingabcchart with minutes:int ":" seconds:int "." ms:int

解析前的旧结果

生成时间 [UTC]:somethingabc:somethingabcchart

2021 年 9 月 8 日上午 9:37:01.532 : 00:27.49 : 00:27.49
2021 年 9 月 8 日,上午 9:38:22.112 : 00:25.67 : 00:25.67
2021 年 9 月 8 日,上午 9:39:51.473 : 00:30.50 : 00:30.50
2021 年 9 月 8 日,上午 9:41:31.722 : 00:33.89 : 00:33.89
2021 年 9 月 8 日,上午 9:43:01.623 : 00:28.10 : 00:28.10
2021 年 9 月 8 日,上午 9:44:31.567 : 00:27.18 : 00:27.18

Current result

图像显示了检查此链接后的当前结果 How to convert string column to time column type?在这里,我希望将时间戳日期转换为秒,正如您在图像中看到的那样,它应该在“somethingabcchart”列下给出 95 秒

00:27.49 仅给出 27 秒如果它是01.01.00 然后只有 61 秒作为 someabc 列或 someabcchart 列下的结果,因为它在时间戳日期中,所以不可能在 azure 查询上创建图表,因此需要一种方法来转换为秒。我正在尝试将其转换为string 因为它认为代码的后面部分可以转换回 timedate 然后除以 1 秒来获取秒数,但无法获取数据,我使用此链接作为指导。 << https://learn.microsoft.com/en-us/azure/data-explorer/kusto/query/scalar-data-types/timespan

最佳答案

如果我正确理解你的问题,你可以划分 timespan1s获取总秒数。

参见:https://learn.microsoft.com/en-us/azure/data-explorer/kusto/query/datetime-timespan-arithmetic

例如:

datatable(ts:timespan)[timespan(12:34:56), timespan(1.23:45:23.678)]
| extend total_seconds = ts / 1s // <---
<表类=“s-表”><标题>tstotal_seconds <正文>12:34:56452961.23:45:23.6780000171923.678

或者,如果输入是 string而不是timespan :

datatable(ts_str:string)["12:34:56", "1.23:45:23.678"]
| extend ts = totimespan(ts_str)
| extend total_seconds = ts / 1s // <---
<表类=“s-表”><标题>ts_strtstotal_seconds <正文>12:34:5612:34:56452961.23:45:23.6781.23:45:23.6780000171923.678

关于azure - 如何在azure kusto查询中将todatetime转换为秒,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69131996/

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