Not weekday

A

Arne Hegefors

Hello! I have a piece of code that I want to use to check if a certain date
is not a weekday, i.e. Saturday or Sunday. The date is found in the first
position of an array. Code:

If (Day(strStartDatumArray(0)) = 1 Or 7) Then
MsgBox ("not a weekday")
End If

Problem: I get the message that it is not a weekday regardless of what day
it actually is. Can anyone please see what is wrong with this code? Thanks
very much in advance!
 
N

News

Arne,
Try this:
Debug.Print Weekday(Now(), vbSunday)

There are a few options for the 2nd argument, depending what you want.

NickHK
 
G

Gary Keramidas

i use something like this, with DtVal being the variable holding the date

If Weekday(DtVal, 2) > 5 then
 
R

Ron Rosenfeld

Hello! I have a piece of code that I want to use to check if a certain date
is not a weekday, i.e. Saturday or Sunday. The date is found in the first
position of an array. Code:

If (Day(strStartDatumArray(0)) = 1 Or 7) Then
MsgBox ("not a weekday")
End If

Problem: I get the message that it is not a weekday regardless of what day
it actually is. Can anyone please see what is wrong with this code? Thanks
very much in advance!


What was the problem with the answers that were posted to you same question
about an hour ago? It would be useful to give the results of those attempts,
before just blindly repeating the question.
--ron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top