By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,990 Members | 2,138 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,990 IT Pros & Developers. It's quick & easy.

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

P: n/a
Please suggest how to get date correponding to 2nd wednesday of each
month ?

Mar 27 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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

Mar 27 '06 #2

P: n/a
Op 27 Mar 2006 14:08:07 -0800 schreef am********@gmail.com:
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


I replied earlier, but something must have gone wrong because I cannot find
my post.

Check your code, because it will fail on Wednesdays. In another group you
mentioned that this is only run on the first of the month. This means you
have until November to figure out what to do:-)

Renze de Waal.
Mar 29 '06 #3

P: n/a

<am********@gmail.com> wrote in message
news:11*********************@i39g2000cwa.googlegro ups.com...
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


Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim dtWed2 As Date
dtWed2 = New DateTime(DateTimePicker1.Value.Year, _
DateTimePicker1.Value.Month, 8)
If dtWed2.DayOfWeek <> DayOfWeek.Wednesday Then
dtWed2 = DateAdd(DateInterval.Day, _
Choose(dtWed2.DayOfWeek + 1, 3, 2, 1, 0, 6, 5, 4), dtWed2)
End If
TextBox1.Text = dtWed2.ToShortDateString
End Sub
Apr 3 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.