S
S
Shalimo2015-06-05 12:33:57
Algorithms
Shalimo, 2015-06-05 12:33:57

How to calculate the number of working hours between two dates?

Interested in the algorithm for calculating working hours between dates

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuri Tarakhonich, 2015-06-05
@sofcase

You could at least clarify the input data.
Suppose there are 8 working hours in a day.
We take the difference between the dates and multiply by 8 hours. For example:
D1: 06/13/2015
D2: 06/24/2015
Work. hours: (06/24/2015 - 06/13/2015) * 8 = 11 * 8 = 88 hours.
But here we must also take into account weekends, i.e. do not stupidly subtract a smaller date from a large date, but iteratively look at each date, if it is a day off, then skip, if it is a worker, then increment the number of days.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question