Documentation

boundaries.week() function

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 "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 "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 "date/boundaries"

thisWeek = boundaries.week()

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

Query data from last week

import "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!


Introducing InfluxDB Clustered

A highly available InfluxDB 3.0 cluster on your own infrastructure.

InfluxDB Clustered is a highly available InfluxDB 3.0 cluster built for high write and query workloads on your own infrastructure.

InfluxDB Clustered is currently in limited availability and is only available to a limited group of InfluxData customers. If interested in being part of the limited access group, please contact the InfluxData Sales team.

Learn more
Contact InfluxData Sales

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.

Flux is going into maintenance mode and will not be supported in InfluxDB 3.0. This was a decision based on the broad demand for SQL and the continued growth and adoption of InfluxQL. We are continuing to support Flux for users in 1.x and 2.x so you can continue using it with no changes to your code. If you are interested in transitioning to InfluxDB 3.0 and want to future-proof your code, we suggest using InfluxQL.

For information about the future of Flux, see the following:

State of the InfluxDB Cloud Serverless documentation

InfluxDB Cloud Serverless documentation is a work in progress.

The new documentation for InfluxDB Cloud Serverless is a work in progress. We are adding new information and content almost daily. Thank you for your patience!

If there is specific information you’re looking for, please submit a documentation issue.