2 of 2 people found this helpful
// CALCULATE THE NUMBER OF SATURDAY'S AND SUNDAY'S BETWEEN TWO DATES (INCLUSIVE)
// Count the number of Saturday's
// (hint, the closer you get to Saturday, the more likely we are to add another week)
int( (DATEDIFF('day',[Start Dt],[End Dt])+DATEPART('weekday',[Start Dt])) /7 )
// Double the Saturday count (will need to fix if there is only one Saturday or Sunday)
// Now deal with single day weekend overlaps that were missed or over compensated for
// Add 1 because we have one more Sunday than we thought
// (i.e. no Saturday, but there is a Sunday)
+ (if DATEPART('weekday',[Start Dt]) = 1 then 1 else 0 end)
// Subtract 1 because we have one less Sunday than we thought
// (i.e. period ended on Saturday, but we added an extra Sunday count above)
- (if DATEPART('weekday',[End Dt]) = 7 then 1 else 0 end)
Thank you! Exactly what I was looking for!
How i can count business days excluding Saturdays and Sundays and holidays with two different dates.