Todays date is it a weekday?

  • Thread starter Russ via AccessMonster.com
  • Start date
R

Russ via AccessMonster.com

What can I use to find out if the current date is a weekday?
example:

MyDate = Date()

If MyDate = weekday then
MsgBox "Yes MyDate is a weekday"
End if
 
T

Tom Lake

Russ via AccessMonster.com said:
What can I use to find out if the current date is a weekday?
example:

MyDate = Date()

If MyDate = weekday then
MsgBox "Yes MyDate is a weekday"
End if

Try this:

MyDate = Format(Date(), "ddd")
If MyDate <> "Sat" And MyDate <> "Sun" Then
MsgBox "Yes MyDate is a weekday"
End If


Tom Lake
 
R

Russ via AccessMonster.com

Thanks, I will try that!

Tom said:
What can I use to find out if the current date is a weekday?
example:
[quoted text clipped - 4 lines]
MsgBox "Yes MyDate is a weekday"
End if

Try this:

MyDate = Format(Date(), "ddd")
If MyDate <> "Sat" And MyDate <> "Sun" Then
MsgBox "Yes MyDate is a weekday"
End If

Tom Lake
 
R

RuralGuy

Here's another method Russ:

If Weekday(Date(), vbMonday) <= 5 Then
MsgBox "Yes MyDate is a weekday"
End if

What can I use to find out if the current date is a weekday?
example:

MyDate = Date()

If MyDate = weekday then
MsgBox "Yes MyDate is a weekday"
End if

_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.
 
P

PC Datasheet

Put the following function in a standard module:
Function IsWeekDay(DateToCheck As Date) As Boolean
IsWeekDay = (WeekDay(DateToCheck) > 1 And WeekDay(DateToCheck) < 7 )
End Function

IsWeekDay will be True if the Date To Check is a weekday.

Add the following code to your code:
If IsWeekDay(Me!MyDate) Then
<Do this if today is a weekday>
Else
<Do this if today is on a weekend>
End If
 
D

David C. Holley

Make that
DatePart("w", Date())

w - returns the weekday (1-7) of the date provided
d - returns the day of the month (1-31) of the date provided
 
D

David C. Holley

I've had wayyy to many this weekend

If (DatePart("w", Date()) > 1) and (DatePart("w", DatePart)) <7) Then
 
R

Russ via AccessMonster.com

Wow, so many great ideas!
But Tom's Idea did the trick for me.
Thanks everyone!
Russ

Tom said:
What can I use to find out if the current date is a weekday?
example:
[quoted text clipped - 4 lines]
MsgBox "Yes MyDate is a weekday"
End if

Try this:

MyDate = Format(Date(), "ddd")
If MyDate <> "Sat" And MyDate <> "Sun" Then
MsgBox "Yes MyDate is a weekday"
End If

Tom Lake
 
A

Alex Dybenko

Hi,
Using day names can cause a problem in non-english installations, so better
to use day number

--
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com


Russ via AccessMonster.com said:
Wow, so many great ideas!
But Tom's Idea did the trick for me.
Thanks everyone!
Russ

Tom said:
What can I use to find out if the current date is a weekday?
example:
[quoted text clipped - 4 lines]
MsgBox "Yes MyDate is a weekday"
End if

Try this:

MyDate = Format(Date(), "ddd")
If MyDate <> "Sat" And MyDate <> "Sun" Then
MsgBox "Yes MyDate is a weekday"
End If

Tom Lake
 
D

David C. Holley

course it would be nice if MS added a IsWeekday() and/or IsWeekend() or
even startOfWeek() and endOfWeek() - SOW, EOW giving the Sunday/Saturday
before and after a given date.
 
R

RuralGuy

David, MS has given you all of the tools to roll your own!

course it would be nice if MS added a IsWeekday() and/or IsWeekend() or
even startOfWeek() and endOfWeek() - SOW, EOW giving the Sunday/Saturday
before and after a given date.

_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.
 
D

David C. Holley

So what your saying is that I need to start using Library db's? Oh fun.
Course I do try to design stuff as generic as possible.....
 
D

Dirk Goldgar

David C. Holley said:
So what your saying is that I need to start using Library db's? Oh
fun. Course I do try to design stuff as generic as possible.....

Look at Rural Guy's reply to Russ's question.
 
Top