How would I get last week Wednesday and next week Wednesday\'s date in C#:
public Form1()
{
InitializeComponent();
CurrentDate.Text = \"Today\'s Date: \" +
You can use this to calculate it:
DateTime day = DateTime.Today;
while (day.DayOfWeek != DayOfWeek.Wednesday)
day = day.AddDays(-1);
var currentRent = day;
var nextRent = day.AddDays(7);
Note that if today is Wednesday, this will show currentRent
as today, not nextRent
as today. If you want this reversed, you can reverse the logic.
DateTime day = DateTime.Today;
while (day.DayOfWeek != DayOfWeek.Wednesday)
day = day.AddDays(1);
var currentRent = day.AddDays(-7);
var nextRent = day;