boundaries.month() 函数
boundaries.month() 返回一个记录,包含当前月份的 start 和 stop 边界时间戳。
now() 确定当前月份。
函数类型签名
(?month_offset: int) => {stop: time, start: time}
有关更多信息,请参见 Function type signatures。
参数
月份偏移
从当前月份开始偏移的月份数。默认值是 0。
使用负偏移量返回先前月份的边界。使用正偏移量返回未来月份的边界。
示例
返回当前月份的开始和结束时间戳
import "date/boundaries"
option now = () => 2022-05-10T10:10:00Z
boundaries.month(
)// Returns {start:2022-05-01T00:00:00.000000000Z, stop:2022-06-01T00:00:00.000000000Z}
查询本月的数据
import "date/boundaries"
thisMonth = boundaries.month()
from(bucket: "example-bucket")
|> range(start: thisMonth.start, stop: thisMonth.stop)
查询上个月的数据
import "date/boundaries"
lastMonth = boundaries.month(month_offset: -1)
from(bucket: "example-bucket")
|> range(start: lastMonth.start, stop: lastMonth.stop)