content/flux/v0/stdlib/experimental/date/boundaries/week.md
boundaries.week() returns a record with start and stop boundary timestamps of the current week.
By default, weeks start on Monday.
(?start_sunday: bool, ?week_offset: int) => {stop: time, start: time}
{{% caption %}} For more information, see Function type signatures. {{% /caption %}}
Indicate if the week starts on Sunday. Default is false.
When set to false, the week starts on Monday.
Number of weeks to offset from the current week. Default is 0.
Use a negative offset to return boundaries from previous weeks. Use a positive offset to return boundaries for future weeks.
import "experimental/date/boundaries"
option now = () => 2022-05-10T00:00:00.00001Z
boundaries.week(
)// Returns {start: 2022-05-09T00:00:00.000000000Z, stop: 2022-05-16T00:00:00.000000000Z}
import "experimental/date/boundaries"
option now = () => 2022-05-10T10:10:00Z
boundaries.week(
start_sunday: true,
)// Returns {start: 2022-05-08T00:00:00.000000000Z, stop: 2022-05-14T00:00:00.000000000Z}
import "experimental/date/boundaries"
thisWeek = boundaries.week()
from(bucket: "example-bucket")
|> range(start: thisWeek.start, stop: thisWeek.stop)
import "experimental/date/boundaries"
lastWeek = boundaries.week(week_offset: -1)
from(bucket: "example-bucket")
|> range(start: lastWeek.start, stop: lastWeek.stop)