i have a problem, i have a table with 3 columns
- date - varchar2 - varchar2 -
| date | start_hour | end_hour |
I need to make a validation to not overlap hour ranges.
For example:
| date | start_hour | end_hour |
| date1 | 09:00AM | 09:30AM |
| date1 | 10:30AM | 11:30AM |
| date1 | 01:00PM | 03:00PM |
Assuming the date is the same for the 3 rows.
What i need is, to no overlap these ranges
I cant insert a ranges like this
start_hour = 08:00AM and end_hour = 09:20AM, because, a range between 09:00AM and 09:30AM already exist, so, the new range clashes with the range who exist in the table.
I tried so many querys, with not between, the end_hour i insert need to be less than the start_hour from a table.
Anyone have an idea how to do it?
i already found the solution to my problem, as a recomendation from a comment in my question, when i changed the format of the hours, and the format of the new hours, it worked perfectly. Here is the code for someone who have this same issue in the future.
Thanks for all our help.
I assume that you have converted your time format to
hh24:mi
maybe this could help:
or you can use
between
to check itstart_hour
orend_hour
ist between the valuesdb<>fiddle here