Given a date as input, how can I determine whether the day falls on a weekend?
To filter weekdays or weekend days, you apply Excel's filter to your table (Data tab > Filter) and select either "Workday" or "Weekend".
To do this you have to add the Days Between to the Day of the Week, and then FLOOR that value to get the highest integer result. You then divide that number by 7 to get the amount of WEEKS and then multiply that by 2 to calculate the amount of WeekEnd days. Name this calculation "Weekend days".
What does weekend mean? The weekend is most commonly considered the period between Friday evening and the end of Sunday. More strictly speaking, the weekend is thought to consist of Saturday and Sunday (often regardless of whether the calendar week is considered to begin on Sunday or Monday).
There is a Weekday function that takes a Date as an argument and returns the day (1, 2, 3, etc.)
The return values are:
vbSunday (1) vbMonday (2) vbTuesday (3) vbWednesday (4) vbThursday (5) vbFriday (6) vbSaturday (7)
Assuming that weekends are Saturday and Sunday, the function would look like this:
Public Function IsWeekend(InputDate As Date) As Boolean Select Case Weekday(InputDate) Case vbSaturday, vbSunday IsWeekend = True Case Else IsWeekend = False End Select End Function
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With