Hi Karen Bashaw
Try with below expression to check the rule for print_date and ship_date.
=IIf((DateDiff("d", DateValue(Fields!print_date.Value), DateValue(Fields!ship_date.Value))
- (
( (DateDiff("d", DateValue(Fields!print_date.Value), DateValue(Fields!ship_date.Value)) \ 7 ) * 2 )
+ IIf( (DatePart("w", DateValue(Fields!print_date.Value)) + (DateDiff("d", DateValue(Fields!print_date.Value), DateValue(Fields!ship_date.Value)) Mod 7 ) -1 ) >=7, 1, 0 )
+ IIf( DatePart("w", DateValue(Fields!print_date.Value)) <=1 Or (DatePart("w", DateValue(Fields!print_date.Value)) + (DateDiff("d", DateValue(Fields!print_date.Value), DateValue(Fields!ship_date.Value)) Mod 7 ) -1 ) >=8, 1, 0 )
)
) >= 2,
"Red",
"Transparent"
)
Or using custom code.
Public Function BusinessDaysBetween(startDate As Date, endDate As Date) As Integer
Dim count As Integer = 0
Dim current As Date = startDate
While current <= endDate
' Check if the day is a weekday (Monday to Friday)
If Weekday(current, vbMonday) <= 5 Then
count = count + 1
End If
current = DateAdd("d", 1, current)
End While
Return count - 1 ' Exclude the start date if needed
End Function
And then use the code in your expression:
=IIf(Code.BusinessDaysBetween(DateValue(Fields!print_date.Value), DateValue(Fields!ship_date.Value)) >= 2, "Red", "Transparent")
Regards,
Zoe Hui
If the answer is helpful, please click "Accept Answer" and upvote it.