Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine if a date falls on the weekend?

Tags:

Given a date as input, how can I determine whether the day falls on a weekend?

like image 427
JR. Avatar asked Oct 16 '09 21:10

JR.


People also ask

How do you find if a date is weekend in Excel?

To filter weekdays or weekend days, you apply Excel's filter to your table (Data tab > Filter) and select either "Workday" or "Weekend".

How do you find the weekend between two dates?

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 is a weekend date?

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).


1 Answers

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 
like image 101
Lawrence P. Kelley Avatar answered Sep 24 '22 05:09

Lawrence P. Kelley