Kool
I got a little intrigued
.
See what i accomplished so far:
Got from data provider:
Month name
<FIRST_DATE> is first date of each month
Create these variables:
<Last Day> = LastDayOfMonth(<FIRST_DATE>)
<Day> = =DayNumberOfWeek(<Last Day>)
<Month Days> = =DaysBetween(<FIRST_DATE> ,LastDayOfMonth(<FIRST_DATE>))+1
<Diff 6> = 4 + If <Day> InList (1 , 7) Then 1 Else If <Day> = 2 Then If <Month Days>=31 Then 1 Else 0 Else 0
As a month can be 28+0/1/2/3 days it will always have 4 full weeks so first 4 holidays are set when we have 6 working days,
also we know that in the following +1/2/3 days we can have additional holidays
<Week End 6> = <Month Days>-<Diff 6>
Te same logic but a litle more complicated goes in case of 5 working days
Even here we have a set of 28 days per month which asures us an 8 holidays
for the other 3 possible days we will check using three variables.
<Day 30 31 5> = <Month Days>-30
Check if the month has 31 days if not will be 0 or negative.
<Day 7-30 5>=Floor(<Day>/6)*Mod((<Month Days>-30)+1 ,2)
Check if the last day of month falls on the last weekend and if the month has 31 days
<Day Odd 5> = If Mod(<Day> ,6) = 1 Then 1 Else 0
Check if the Last day of month falls in day of week 1,7. it means we will have 2 working days
<Diff 5> = If <Month Days> = 28 Then 0 Else If <Month Days> = 29 Then If <Day> InList(6 ,7) Then 1 Else 0 Else If <Day> InList(1 ,2 ,6 ,7) Then <Day 30 31 5>+<Day 7-30 5>+<Day Odd 5> Else 0
Last checking for 28-29 February before giving the value
<Week End 6>=<Month Days>-8-<Diff 5>
Your requirement for 5 working days. Also Note that again we have 8 fixed holidays from 4 full weeks.
See also attached the jpg and the report

test.rep (60.0 KB)
AldoWeb
(BOB member since 2005-05-24)