I have a database containing events. Each event has a timestamp. Events are evenly distributed every other day, but every night there is a period of time without data. My problem is that the night is not defined. It can be from 23:00 to 7:00 the next day, or from 2:00 to 10:00 on the same day, or even from 8 pm to 23 pm on the same day.
Now I want to calculate the interval of events, but without long periods of time without events. But I do not know how to find this period of time. My problem is that there can be days without a difference or two days with the same time interval (for example, from 8 pm to midnight on the first day, from midnight to 7 am on the second day).
My question is: how to find this period of time?
I would prefer a solution only in MySql, but if that is not possible, you could use PHP too.
source share