473,403 Members | 2,222 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

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

Please suggest how to get date correponding to 2nd wednesday of each
month ?

Mar 27 '06 #1
3 1866
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
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

<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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: androtech | last post by:
Hello, I'm looking for a function that returns a date range for a specified week number of the year. I'm not able to find functions like this anywhere. Any pointers/help would be much...
4
by: Richard Hollenbeck | last post by:
I'm trying to write some code that will convert any of the most popular standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan 1908) and compare the first with the second and...
38
by: | last post by:
I have a script... ----- <SCRIPT language="JavaScript" type="text/javascript"> <!-- function makeArray() { for (i = 0; i<makeArray.arguments.length; i++) this = makeArray.arguments; } ...
2
by: amit.gaind | last post by:
How to get date correponding to 2nd wednesday of each month.
12
by: Assimalyst | last post by:
Hi, I have a working script that converts a dd/mm/yyyy text box date entry to yyyy/mm/dd and compares it to the current date, giving an error through an asp.net custom validator, it is as...
5
by: cbalian | last post by:
I am looking for a TSQL code that would calculate a specific date each month that varies based on the following condition: I need the result that would return the date of the Thursday after the...
1
by: Presto | last post by:
I have two date fields. PaymentDate - is set to default to today : =Date() MeetingDate - is going to find the next meeting date after the PaymentDate So using April as an example: If...
16
by: W. eWatson | last post by:
Are there some date and time comparison functions that would compare, say, Is 10/05/05 later than 09/22/02? (or 02/09/22 format, yy/mm/dd) Is 02/11/07 the same as 02/11/07? Is 14:05:18 after...
0
by: Hendrik van Rooyen | last post by:
John Machin <sj..con.netwrote: This will work nicely for negative values of D. The case of positive D values is more of a toffee: Its Wednesday and I make some observations. Its Thursday...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.