Query data by week

Hi,

Can I know whether I can query data by week and show only that specific week data. For example, I query at 7/7/2021 then it will show only the data from 1/7/2021-7/7-2021, and when I query at 8/7/2021 then it will only show data start from 8/7/2021 till 14/7/2021.

Thank you.

Sure, specify a start time and end time in range()

1 Like

For range() function, we need to specify a start time and end time. If I want to query it automatically in an application every week, what should I do? Thank you.

  1. Calculate the date offset for start and/or end, and pass those into your flux query as you construct it,

or

  1. use the relative time offsets built into flux language , eg
from(bucket:"example-bucket")
  |> range(start: -168h)
2 Likes

Thanks for your help, I’m able to get what I want with the method you mentioned.

1 Like