How to get date correponding to 2nd wednesday of each month.

  • Thread starter Thread starter amit.gaind
  • Start date Start date
Ok, I got it myself..
If Today.DayOfWeek < DayOfWeek.Wednesday Then
dt2ndWednesday = DateAdd("d", (DayOfWeek.Wednesday -
Today.DayOfWeek) + 7, Today)
ElseIf Today.DayOfWeek > DayOfWeek.Wednesday Then
dt2ndWednesday = DateAdd("d", 14 - (Today.DayOfWeek -
DayOfWeek.Wednesday), Today)
End If
 
Without trying to understand what the code means I can tell you that it will
fail on Wednesdays:-)

If you don't know what I mean, you will be abl eto test it soon. Follow the
logic when today.dayofweek = dayofweek.wednesday.

Renze de Waal
 
Back
Top