Forum Discussion
PaulPeterson2
5 years agoQrew Trainee
This should give you a good starting point:
------------------------------
Paul Peterson
------------------------------
If(DayOfWeek(endDate) > 3, 0, ToDays(NextDayOfWeek(startDate, 3) - startDate)) + (Int(ToDays(If(ToDays(endDate - NextDayOfWeek(endDate, 0)) = 7, endDate, NextDayOfWeek(endDate, 0)) - If(ToDays(NextDayOfWeek(startDate, 6) - startDate) = 7, startDate, NextDayOfWeek(startDate, 6))) / 7) * 4 )+ If(DayOfWeek(endDate) > 3, 0, ToDays(endDate - PrevDayOfWeek(endDate, 0)))
------------------------------
Paul Peterson
------------------------------
PaulPeterson2
5 years agoQrew Trainee
Sorry, just noticed an error.
Try This instead:
If(DayOfWeek(startDate) > 3, 0, ToDays(NextDayOfWeek(startDate, 3) - startDate)) +
(Int(ToDays(If(ToDays(endDate - NextDayOfWeek(endDate, 0)) = 7, endDate, NextDayOfWeek(endDate, 0)) - If(ToDays(NextDayOfWeek(startDate, 6) - startDate) = 7, startDate, NextDayOfWeek(startDate, 6))) / 7) * 4 )+ If(DayOfWeek(endDate) > 3, 0, ToDays(endDate - PrevDayOfWeek(endDate, 0)))
------------------------------
Paul Peterson
------------------------------
Try This instead:
If(DayOfWeek(startDate) > 3, 0, ToDays(NextDayOfWeek(startDate, 3) - startDate)) +
(Int(ToDays(If(ToDays(endDate - NextDayOfWeek(endDate, 0)) = 7, endDate, NextDayOfWeek(endDate, 0)) - If(ToDays(NextDayOfWeek(startDate, 6) - startDate) = 7, startDate, NextDayOfWeek(startDate, 6))) / 7) * 4 )+ If(DayOfWeek(endDate) > 3, 0, ToDays(endDate - PrevDayOfWeek(endDate, 0)))
------------------------------
Paul Peterson
------------------------------