Filter values to start on specific date (Year to Year Filter)

Hy All!
I have a question on an specific Date Filter.
i need to display only values starting on a specific Date (01.03) on every year - so i need the filter that all values will be displayed started from this date till today.
An example, today should be only displayed the values from 01.03 till 02.05

How is this possible?

@Gabs_Werni I’m not sure I fully understand the question, but let me see if I can answer each part one at a time.

This is only possible using Flux, so I’ll assume that’s what you’re using. You need to query the full time range that you want data from. Then, you can use the date package to evaluate each part of the month in a filter. Just note, that if you’re full time range includes a lot of data, this filtering process will definitely increase your query’s execution time.

import "date"

from(bucket: "example-bucket")
    |> range(start: -5y, stop: now())
    |> filter(fn: (r) => r._measurement == "example-measurement")
    |> filter(fn: (r) => r._field == "example-field")
    |> filter(fn: (r) => date.month(t: r._time) == 1 and date.monthDay(t: r._time) == 3)

If you’re just trying to define a simple time range, you do this in the range() function:

from(bucket: "example-bucket")
    |> range(start: 2024-01-03, stop: 2024-02-05)
    // ...

thx you very much @scott!
how can i handle this “RANGE” function with only a start date:
from(bucket: “example-bucket”)
|> range(start: 2024-01-03, stop: 2024-02-05)
// …

So STOP should always be today.
So i need only the Range Start without an stop.

thx very much

1 Like

The default for the stop parameter is the current time (now()). So just omit the stop parameter from range and it will work. The Get started querying data documentation will walk you through how to perform basic queries with Flux.