function workAdditionTime (works,worke)
dim resultArr,WorkDay,StartArr,EndArr,i,j,Cs,Ce,ts,te
resultArr=array(0,0,0,0)
StartArr=array(0,1,8,22)
EndArr=array(1,8,22,24)
WorkDay=DateDiff("d",works,worke)
for i=0 to WorkDay
Cs=0:Ce=24
if i=0 then Cs=Hour(works)
if i=WorkDay then Ce=Hour(worke)
for j=0 to ubound(resultarr)
ts=StartArr(j)
te=EndArr(j)
if Cs>=ts then ts=Cs
if Ce<=te then te=Ce
if (ts<te) then resultArr(j)=resultArr(j)+te-ts
next
next
workAdditionTime=resultArr
end function
Function getOverTime(d1,d2,start,interval)
dim sum
sum=0
For d = day(d1) To day(d2)
currentS=DateAdd("d",d-day(d1),CDate(FormatDateTime(d1,2)&" "&start))
currentE=DateAdd("h",interval,CDate(currentS))
if DateDiff("h",d1,currentS)>=0 and DateDiff("h",d1,currentE)>=0 and DateDiff("h",d2,currentS)<=0 and DateDiff("h",d2,currentE)<=0 then
sum=sum+interval
else if DateDiff("h",d1,currentS)<=0 and DateDiff("h",d1,currentE)>=0 and DateDiff("h",d2,currentS)<=0 and DateDiff("h",d2,currentE)<=0 then
sum=sum+DateDiff("h",d1,currentE)
else if DateDiff("h",d1,currentS)>=0 and DateDiff("h",d1,currentE)>=0 and DateDiff("h",d2,currentS)<=0 and DateDiff("h",d2,currentE)>=0 then
sum=sum+DateDiff("h",currentS,d2)
end if
end if
end if
Next
getOverTime=sum
end Function
Function getOverTime(d1,d2,start,interval)
dim sum
sum=0
For d = day(d1) To day(d2)
currentS=DateAdd("d",d-day(d1),CDate(FormatDateTime(d1,2)&" "&start))
currentE=DateAdd("h",interval,CDate(currentS))
if DateDiff("h",d1,currentS)>=0 and DateDiff("h",d1,currentE)>=0 and DateDiff("h",d2,currentS)<=0 and DateDiff
("h",d2,currentE)<=0 then
sum=sum+interval
else if DateDiff("h",d1,currentS)<=0 and DateDiff("h",d1,currentE)>=0 and DateDiff("h",d2,currentS)<=0 and DateDiff
("h",d2,currentE)<=0 then
sum=sum+DateDiff("h",d1,currentE)
else if DateDiff("h",d1,currentS)>=0 and DateDiff("h",d1,currentE)>=0 and DateDiff("h",d2,currentS)<=0 and DateDiff
("h",d2,currentE)>=0 then
sum=sum+DateDiff("h",currentS,d2)
end if
end if
end if
Next
getOverTime=sum
end Function