가벼운 배움/Oracle
예외시간 체크(시간대 및 일자별)
호홍홍집
2016. 7. 5. 11:52
예외시간처리시 시간단위 체크와 일자 단위 체크를 함께 처리하기(내맘대로..ㅋㅋ)
select * from tb_items_exp
where
(
(to_char(stime,'YYYYMMDDHH24MI') <= '201607020900' and to_char(etime,'YYYYMMDDHH24MI') > '201607020900') or
(to_char(stime,'YYYYMMDDHH24MI') >= '201607020900' and to_char(stime,'YYYYMMDDHH24MI') < '201607020910' and to_char(etime,'YYYYMMDDHH24MI') > '201607020900' and to_char(etime,'YYYYMMDDHH24MI') <= '201607020910') or
(to_char(stime,'YYYYMMDDHH24MI') < '201607020910' and to_char(etime,'YYYYMMDDHH24MI') >= '201607020910')
) and isallday = 'N'
union all
select * from tb_items_exp
where
'20160720' between to_char(sdate,'YYYYMMDD') and to_char(edate,'YYYYMMDD') and isallday = 'Y'
;
isallday = 'N' : 시간대별 체크 건, isallday = 'Y' : 일자별 체크