This is a sample of my input:

Then, I have midnights in a consequent days and I would like to achieve this result automatically:

To put it in words: I have datetimes in one column and I would like to find the last datetime which is before midnight of a day and first datetime which is after this midnight. There can be none, one or more than one datetime for one day. I also need to find a value which is in a column next to the original input.

FYI: input data are snapshots of my gasmeter. Number in Value column is a total cubic meters spent before time in first column. I need to find those border values to calculate spending in a day. I am able to do the calculation, but I cannot manage to find those values in the input.

Thank you!