How would I get last week Wednesday and next week Wednesday\'s date in C#:
public Form1()
{
InitializeComponent();
CurrentDate.Text = \"Today\'s Date: \" +
DateTime.Now.AddDays(7)
and DateTime.Now.AddDays(-7)
is how you can do arithmetic, assuming you are on Wednesday. If you aren't, what you would need to do is use the DayOfWeek
property to determine the number of days (positive and negative) that you would need to determine which day is 'Wednesday'. Then you can pass that value into AddDays
.
For instance, if today was tuesday, you would AddDays(-6)
for last Wednesday and AddDays(8)
for next Wednesday.
I'll leave you the task of calculating those.