学习Kusto查询并寻找获取当月日期时间开始的方法。截至我发布这篇文章的时间是2020年2月25日,因此输出应如下所示,表示2020年2月1日

这就是我到目前为止所做的工作,但应该有更好的方法来做到这一点。有没有人可以告诉我这个查询是否可以改进?获取本月初的常见做法是什么?
下面,获取年份和月份,如果月份需要,则添加前导0,然后连接字符串并将其赋值给变量"d“,该变量看起来像"2020-02-01”,并将该字符串传递给todatetime()
let year = datetime_part("Year",now());
let month = datetime_part("Month",now());
let m = case(month < 10, strcat("0", month), tostring(month));
let d = strcat(year, "-", m, "-01" );
print todatetime(d);发布于 2020-02-26 06:58:39
尝试使用startofmonth()函数。
示例:
MyKustoTable
| project MonthStart = startofmonth(datetime('2020-2-5')) 参考:https://docs.microsoft.com/en-us/azure/kusto/query/startofmonthfunction
发布于 2020-02-26 06:58:52
有一个startofmonth()函数:https://docs.microsoft.com/en-us/azure/kusto/query/startofmonthfunction
https://stackoverflow.com/questions/60404328
复制相似问题