Use Weekday to get the weekday value from a date : Weekday « Date Functions « VBA / Excel / Access / Word






Use Weekday to get the weekday value from a date

 
Private Sub myTime1()
    Dim time As Date
    Dim theHour As Integer
    Dim theDayOfTheWeek As Integer
    time = Now
    theHour = Hour(time)
    theDayOfTheWeek = Weekday(time)
    If (theHour > 8) And (theHour < 17) Then
        If (theDayOfTheWeek > 0) And (theDayOfTheWeek < 6) Then
            MsgBox ("You should be at work!")
        Else
            MsgBox ("I love weekends")
        End If
    Else
        MsgBox ("You should not be at work!")
    End If
End Sub

 








Related examples in the same category

1.Weekday(date) returns A Variant/Integer containing the day of the week represented by date
2.Weekday(Date)
3.Get the weekend between startDate and endDate
4.The Weekday function values