在ORalce 中,怎么判断两个时间段之间是否有交集, 编写的一个函数.


判断2个时间段是否有交集的函数,开始是在我计算考勤的时候有用过,
后来发现用到的地方越来越多, 丢个砖头
9i 下通过.

两个时间段 之间是否有交集 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

 1<intime) (todate="" --请假的开始时间<当天应上班的时间="" if="" then="">=outtime) then --请假的结束时间&gt;=当天应下班时间 说明有交集   
 2Result :=1;   
 3end if;   
 4end if;   
 5if (fromdate&gt;=intime) then -- 如果请假开始时间&gt;应上班时间,只要在下班时间之前,则也说明有集   
 6if (fromdate&lt;=outtime) then   
 7Result :=1;   
 8end if;   
 9end if ;   
10return(Result);   
11end func_IsTimeCross;</intime)>
Published At
Categories with 数据库类
Tagged with
comments powered by Disqus