Documentation

boundaries.week() function

boundaries.week() is experimental and subject to change at any time.

boundaries.week() returns a record with start and stop boundary timestamps of the current week. By default, weeks start on Monday.

Function type signature
(?start_sunday: bool, ?week_offset: int) => {stop: time, start: time}

For more information, see Function type signatures.

Parameters

start_sunday

Indicate if the week starts on Sunday. Default is false.

When set to false, the week starts on Monday.

week_offset

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.

Examples

Return start and stop timestamps of the current week starting on Monday

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}

Return start and stop timestamps of the current week starting on Sunday

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}

Query data from the current week

import "experimental/date/boundaries"

thisWeek = boundaries.week()

from(bucket: "example-bucket")
    |> range(start: thisWeek.start, stop: thisWeek.stop)

Query data from last week

import "experimental/date/boundaries"

lastWeek = boundaries.week(week_offset: -1)

from(bucket: "example-bucket")
    |> range(start: lastWeek.start, stop: lastWeek.stop)

Was this page helpful?

Thank you for your feedback!


The future of Flux

Flux is going into maintenance mode. You can continue using it as you currently are without any changes to your code.

Read more

InfluxDB v3 enhancements and InfluxDB Clustered is now generally available

New capabilities, including faster query performance and management tooling advance the InfluxDB v3 product line. InfluxDB Clustered is now generally available.

InfluxDB v3 performance and features

The InfluxDB v3 product line has seen significant enhancements in query performance and has made new management tooling available. These enhancements include an operational dashboard to monitor the health of your InfluxDB cluster, single sign-on (SSO) support in InfluxDB Cloud Dedicated, and new management APIs for tokens and databases.

Learn about the new v3 enhancements


InfluxDB Clustered general availability

InfluxDB Clustered is now generally available and gives you the power of InfluxDB v3 in your self-managed stack.

Talk to us about InfluxDB Clustered