boundaries.month() 函数
boundaries.month()
返回一个记录,其中包含当前月份的 start
和 stop
边界时间戳。
now()
确定当前月份。
函数类型签名
(?month_offset: int) => {stop: time, start: time}
有关更多信息,请参阅 函数类型签名。
参数
month_offset
从当前月份偏移的月份数。默认为 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)
此页是否对您有帮助?
感谢您的反馈!