How would I get last week Wednesday and next week Wednesday\'s date in C#:
public Form1()
{
InitializeComponent();
CurrentDate.Text = \"Today\'s Date: \" +
You'll want to use the DayOfWeek
enum along with an if-else structure of switch statement to determine how many days to add/subtract for your dates. It's tedious coding but simple.
DateTime nextRent;
DateTime lastRent;
DateTime today = DateTime.Now;
if (today.DayOfWeek == DayOfWeek.Wednesday)
{
nextRent = today.AddDays(7);
lastRent = today.AddDays(-7);
}
else if (today.DayOfWeek == DayOfWeek.Thursday)
{
nextRent = today.AddDays(6);
lastRent = today.AddDays(-8);
}
//ect for all days