Calculating "next Wednesday"

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can someone suggest a date function I could use to
calculate what next Wednesday would be? It will always
be the Wednesday of the following or next week.

Thanks for the help.

Debbie Nelson
 
Semi-untested aircode:

Assuming Sunday is your StartOfWeek:
Weekday( MyDate,1)
will return a value of 1(sunday) to 7(saturday). Wednesday = 4

so, MyDate + (4 - Weekday(MyDate,1) + 7
should return Wed of the following week.

If it is Sunday-Tuesday and you want Wednesday of THIS week returned then i
would create a function and call it from the query:

Function NextWed(dtmDate as Date) as Date
Dim lngDayNum as long

lngDayNum = Weekday(dtmDate,1)

Select Case lngDayNum
Case < 4
' dtmDate is Sun, Mon or Tues: add 3, 2 or 1 days to date
NextWed = dtmDate + (4 - lngDayNum)
Case Else
' Return Wed of Next week: Add 7 days to Wed of this week
NextWed = dtmDate + (4 - lngDayNum) + 7
End Select

End Function
 
Not fully tested, but you might try:

DateAdd("d",4-Weekday(Date),Date()) + 7

This assumes that Sunday is day 1 of your week.
 
Hi Debbie,

There are a couple of ways to discover "next Wednesday." Here is a nested
IIf expression which would return the date of next Wednesday.

Expr1:
IIf(Weekday(Date())=4,Date()+7,IIf(Weekday(Date())=5,Date()+6,IIf(Weekday(Date())=6,Date()+5,IIf(Weekday(Date())=7,Date()+4,IIf(Weekday(Date())=1,Date()+3,IIf(Weekday(Date())=2,Date()+2,IIf(Weekday(Date())=3,Date()+1)))))))

Keep in mind that this necessitates your system date be set correctly.

hth

Judi B
 
Back
Top