Adjust the date to working time

Source: Internet
Author: User

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

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.