Possible Duplicate:
Getting specific days in a month
I've touched on this problem once before, in How to find the 3rd Friday in a month with C#? But since I did not explain my problem well then, I must try again:
My goal here is simple: upon the press of a button (referred to here as "Button1"), I must determine whether today's date is prior to either the first, or the third Wednesday of the month. If this is the case, I must then set the text of a label (referred to here as "lblDate") to the date of whichever of these future Wednesdays is nearest to the current date.
So far, I've written this:
protected void Button1_Click(object sender, EventArgs e)
{
DateTime Now = DateTime.Today;
DateTime TempDate = new DateTime(Now.Year, Now.Month, 1);
if (TempDate.DayOfWeek != DayOfWeek.Wednesday)
{
TempDate = TempDate.AddDays(1);
string date = TempDate.ToString();
lblDate.Text = date;
}
if (TempDate == TempDate.AddDays(1))
{
TempDate = TempDate.AddDays(14);
string date = TempDate.ToString();
lblDate.Text = date;
}
}
As you can see, something is missing. I would greatly appreciate any assistance in filling that in...