数据库

本类阅读TOP10

·SQL语句导入导出大全
·SQL Server日期计算
·SQL语句导入导出大全
·SQL to Excel 的应用
·Oracle中password file的作用及说明
·MS SQLServer OLEDB分布式事务无法启动的一般解决方案
·sqlserver2000数据库置疑的解决方法
·一个比较实用的大数据量分页存储过程
·如何在正运行 SQL Server 7.0 的服务器之间传输登录和密码
·SQL中两台服务器间使用连接服务器

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
在ORalce 中,怎么判断两个时间段之间是否有交集, 编写的一个函数.

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

判断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<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;



相关文章

相关软件