Use the Subtraction method of the DateTime class for computing the number days for your time interval. Divide the number of days by 7 and multiply the result by 2. That gives you the number of leave days of the full 7-day weeks. Divide number of days modulo 7 ( % 7 instead of / 7). This gives you the remaining days which range from 0 through 6. Count the number of leave days contained in this result which is a number in the range from 0 through 2. Add this number to the number of leave days of the complete weeks and you are done.