In Oralce, how to determine whether there is a intersection between two time periods, write a function.
Source: Internet
Author: User
function to determine whether 2 time periods have the intersection of the function, the beginning is in my time to calculate the attendance is useful,
Later found that more and more places to use, to lose a brick
9i Pass.
Is there intersection between two time periods Intime---outtime
Fromdate--todate
If there is an intersection, return 1, otherwise return 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--Start time of leave < time to work on the day
if (todate>=outtime) then--the end of the leave time >= the same day should be off time description has intersection
Result: = 1;
End If;
End If;
if (fromdate>=intime) then-if the leave start time > should work time, as long as the time before the end of work, it also indicates that there is a set
if (fromdate<=outtime) then
Result: = 1;
End If;
End If;
return (result);
End Func_istimecross;
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service