In the request the oracle to specify to specify a delta in 30 minutes (that the personnel could come to the change)

40 views Asked by At

my request is oracle, it works fine without questions.

I use it in the API to check the status of the card (access is allowed, not allowed). But there is a problem in the request

I check the card for activity and work schedule. But I still need to take into account the delta of 30 minutes, before the schedule and after the schedule (so that staff can come earlier and leave later). 30. But I had a problem with the schedule from 00:00 to 23:59.

The problem is that the query does (between) for this schedule from 23:30 to 00:29. Only then a passage is possible. I will be grateful for the help.

Annotated selection (this is a selection with a delta 30 min) the last selection is then selected exclusively for the work schedule (but I do not need it in this form)

 select a.status
  from EM_STATUS_CARD a
     left join EM_CARD b on  a.ID_CARD = b.ID_CARD and  b.del = 'false'
     left join EM_CARD_ZONE v on  a.ID_CARD = v.ID_CARD
     left join EM_EMPLOYEE m on  a.EMPLOYEE_ID = m.guid
     left join EM__WORK_SCHEDULE p on  m.SCHEDULE_ID = p.guid
     INNER JOIN(
                  select MAX(l.id) id, l.ID_CARD
                  from EM_STATUS_CARD l
                  GROUP BY l.ID_CARD
                  ) t
                  on t.id = a.id   AND t.ID_CARD = a.ID_CARD
  where
        a.ID_CARD = '0000003995E0' 
     -- and TO_CHAR (sysdate, 'HH24:MI' ) between  to_char((to_date(p.FROMS, 'HH24:MI') - (1/24/60) * 30), 'HH24:MI ')   and  to_char((to_date(p.tos, 'HH24:MI') + (1/24/60) * 30) , 'HH24:MI')
     and TO_CHAR (sysdate, 'HH24:MI' ) between  p.FROMS and p.tos
                                                                     
0

There are 0 answers