Get the weekend between startDate and endDate : Weekday « Date Functions « VBA / Excel / Access / Word






Get the weekend between startDate and endDate

 
Function TestIfWeekend(startDate, endDate)
  Dim varDate
  TestIfWeekend = "XXX"                  
  If startDate = 0 Then Exit Function    
  If endDate = 0 Then Exit Function      
  If endDate - startDate < 2 Then Exit Function  
  For varDate = startDate To endDate - 1
    If WeekDay(varDate) = 7 Then
      TestIfWeekend = "OK": Exit Function
    End If
  Next varDate
End Function

 








Related examples in the same category

1.Weekday(date) returns A Variant/Integer containing the day of the week represented by date
2.Use Weekday to get the weekday value from a date
3.Weekday(Date)
4.The Weekday function values