兩個時間段 之間是否有交集 intime---outtime fromdate--todate 假如有交集,則返回1,否則返回0 */ create or replace function func_IsTimeCross(intime in date, outtime in date, fromdate date , todate date ) return number is Result number; begin Result :=0; if (fromdate<intime) then --請假的開始時間<當天應上班的時間 if (todate>=outtime) then --請假的結束時間>=當天應下班時間 說明有交集 Result :=1; end if; end if; if (fromdate>=intime) then -- 假如請假開始時間>應上班時間,只要在下班時間之前,則也說明有集 if (fromdate<=outtime) then Result :=1; end if; end if ; return(Result); end func_IsTimeCross;