Sample data at specified time


I need to create a synthetic variable by sampling a data set at midnight every day.
I then need to create the average of the last 6 readings at midnight.
I have used:
last(volts, “1D”)
However the last value in the series is the current value.
i.e. the reading at midnight last night was 4.0. The current reading at 21:30 is 3.87
When I use last(volts, “1D”) I get [. . ., 4.0, 3.87]
I should get [… , 4.0]
How do I eliminate the current value from the time series?
If I use:
last(volts, “1H”)
then the last value is at the end of the last hour, not the current value