0
I have two tables with the following scheme:
data | hora ini | hora fim
-----------|------------|---------
16/08/2016 | 1115 | 1319
16/08/2016 | 1320 | 1419
16/08/2016 | 1420 | 90
Being that in the second table, it already has the records inserted every half hour, as in the example below:
data | hora
-----------|-------
16/08/2016 | 1380
16/08/2016 | 1410
17/08/2016 | 0
17/08/2016 | 30
17/08/2016 | 60
17/08/2016 | 90
17/08/2016 | 120
What I need is that when I update a record from the second table, for example the midnight record, it does a search if there is no record in the first table that "passes between 00:00 and 00:30". That is, if there is a period pointed in the first table that is from 22:00 until 01:00, it should appear in this select.
I can assemble a BETWEEN to return the records, however, when it passes of the midnight he Buga therefore the final hour turns out to be less than the initial.
If date 2 is higher, BETWEEN( D1, D2 ) if date 2 is lower, NOT BETWEEN( D2, D1 )
– Bacco
It doesn’t work like this. I believe my solution looks like this: http://prntscr.com/c7gxs0
– Killer
the solution is not to search for date & time ? Something like ... date between to_date('16/08/2016 23:00','dd/mm/yyyy hh24:mi') and to_date('1708/2016 00:30','dd/mm/yyyy hh24:mi:mi')
– Motta
no, friend, because the date in the to_date parameter comes from the same field, that is, they are not different but equal.
– Killer