around()around()

返回一个 bool 值,该值指示第一个参数是否处于中心值附近的范围内。Returns a bool value indicating if the first argument is within a range around the center value.

语法Syntax

around(value,center,delta)around(value,center,delta)

参数Arguments

  • value:一个计算的数字、日期或时间跨度value: A number, date, or timespan that is evaluated.
  • center:一个数字、日期或时间跨度,表示范围的中心,它被定义为 [(center-delta) ..center: A number, date, or timespan representing the center of the range defined as [(center-delta) .. (center + delta)].(center + delta)].
  • delta:一个数字或时间跨度,表示范围的增量值,它被定义为 [(center-delta) ..delta: A number, or timespan representing the delta value of the range defined as [(center-delta) .. (center + delta)].(center + delta)].

返回Returns

如果值在范围内,则返回 true,如果值在范围外,则返回 falseReturns true if the value within the range, false if the value outside the range. 如果任何参数为 null,则返回 nullReturns null if any of the arguments is null.

示例:根据特定的时间戳筛选值Example: Filtering values around a specific timestamp

以下示例根据特定的时间戳筛选行。The following example filters rows around specific timestamp.

range dt 
    from datetime(2021-01-01 01:00) 
    to datetime(2021-01-01 02:00) 
    step 1min
| where around(dt, datetime(2021-01-01 01:30), 1min)
dtdt
2021-01-01 01:29:00.00000002021-01-01 01:29:00.0000000
2021-01-01 01:30:00.00000002021-01-01 01:30:00.0000000
2021-01-01 01:31:00.00000002021-01-01 01:31:00.0000000