How do it get daily last/max values

I have a counter that resets each day at around 0:00 clock. How do I get the last/max values of each day.

The problem is this counter doesnt get reset at exactly 0:00. Its a little bit off.
How do I make sure i get the last value of every 24h window?

I presume you are using Flux. Do you have an aggregateWindow statement like this?

  |> aggregateWindow(every: 1d, fn: max, createEmpty: false)