Often with date calculations, something starts working at a certain time, and after n hours of work (working time only), what time is expected to be completed DT1?
Suppose the working time is 9:00-18:00, 9 hours a day ... Well, I'll forget about 1 hours at noon.
Now there is dt1 start time, N hours, DT2, end time.
1. If the direct use of DT1 + N, the time is less good, slightly a large, it will be the end of the night or the nth day of the night ... Obviously unreasonable.
2. Consider the time of the work, calculate the next day or the third day to go.
Working 9 hours a day, days: D = N/9
DT2 = dt1 + D
Is it okay? It seems impossible. If the start time is close to work ... Plus this d, D could be 1.5, a day and a half, and it's going to be night again. Further corrections are required.
3. Set dt3 = Dt1 +d
At this point the time is likely to be between 18:00-9:00, that is, non-working time.
18:00-9:00 has a total of 15 hours (9+24-18=15), more than 1 days of work time, so to be segmented processing.
Day: 18:00-3:00 (9 hours): DT2 = dt3 + 15 hours (15/24=0.625)
Over the day: 3:00-9:00:DT2 = dt3 + 1 days + 6 hours (6/24=0.25)
So.. Over.
Pseudo code:
D = N/9
DT3 = dt1 + D
if (hour (DT3) >= or Hour (DT3) <3) Then DT2 = DT3 + 0.625
ElseIf (Hour (DT3) >= 3 and Hour (DT3) <9) Then DT2 = DT3 + 0.25
else DT2 = DT3
There may actually be better functions, but I'm in Excel ... Some trouble.
Adjust the date to working time