Forum Discussion
XavierFan
6 years agoQrew Cadet
Try this formula below - this is assuming that [Completed Date] and [Open Date] are Date/Time fields.
It first looks for [Completed Date] and [Open] date within the same 5 day period in the same week - in which case there are no weekend hours to remove.
Then it checks for the duration being within 5 days, but crossing a weekend - in which case you remove 48 hours.
Finally - it checks for the duration spanning multiple weekends, and removes the total weekend hours.
------------------------------
Xavier Fan
Quick Base Solution Provider
http://xavierfanconsulting.com/
------------------------------
It first looks for [Completed Date] and [Open] date within the same 5 day period in the same week - in which case there are no weekend hours to remove.
Then it checks for the duration being within 5 days, but crossing a weekend - in which case you remove 48 hours.
Finally - it checks for the duration spanning multiple weekends, and removes the total weekend hours.
var Duration TotalDuration = [Completed Date] - [Open Date];
If (
// if less than 7 days and within the same week, then there are no weekend hours to remove
$TotalDuration <= Hours(168)
and DayOfWeek(ToDate([Completed Date])) > DayOfWeek(ToDate([Open Date])),
$TotalDuration,
// if less than 7 days, but crosses a weekend - then remove 48 hours
$TotalDuration <= Hours(168),
$TotalDuration - Hours(48),
// otherwise remove the hours belonging to multiple weekends
$TotalDuration - Hours(Int(ToHours($TotalDuration) / 168) * 48)
)
------------------------------
Xavier Fan
Quick Base Solution Provider
http://xavierfanconsulting.com/
------------------------------