I know that there are many such questions, but I did not see that which was quite similar to my criteria. Therefore, I would like to ask you for help. The fields that I have are just the beginning and the end, which are related to the types of time. I can’t include any specific dates in it. If time ranges do not go through midnight every other day, I would simply compare the two tuples as such:
end1 > start2 AND start1 < end2
(touch endpoints are not considered overlapping here.)
But when I use a time range that passes (or at) midnight, this obviously does not work. For example, given:
start | end
--------+--------
06:00PM | 01:00AM
03:00PM | 09:00PM
Without considering dates, how can I achieve this, please. My assumption is that if the end is less than the initial, then we include 2 days.
I am trying to do this in plain standard SQL, so there is simple and concise logic in the WHERE clause.
Thanks everyone!
Added:
Also, how would I check if one time range completely converts another? Thanks again!
source
share