Move2Next takes one date/time variable and moves it to the beginning of the next work period. To change the hours of the day you have to change the variables in Move2Next, IsWorkTime & CalculateEnd. Read it and try to understand what it is doing. Result = DateSerial(Year(DateX), Month(DateX), Day(DateX)) ((Hour(DateX) >= 8 And Hour(DateX) = 13 And Hour(DateX) <= 16)) Thenįunction CalculateEnd(DateX As Date) As Date If Not IsWorkTime(StartTime) Then Call Move2Next(StartTime)ĭo While StartTime = 13 And Hour(DateX) = 13 And Hour(DateX) = 0 And Hour(DateX) = 8 And Hour(DateX) 6 And Weekday(DateX, 2) 7 And _ Code Function CalculateDownTime(StartTime As Date, EndTime As Date) As Double