How would I get last week Wednesday and next week Wednesday\'s date in C#:
public Form1()
{
InitializeComponent();
CurrentDate.Text = \"Today\'s Date: \" +
private static DateTime FindPreviousDayOfWeek(DateTime fromDate, DayOfWeek findDay,
bool skipSame = false)
{
if (fromDate.DayOfWeek < findDay)
fromDate = fromDate.AddDays(-((int)fromDate.DayOfWeek - 1 + (int)findDay));
else if (fromDate.DayOfWeek > findDay)
fromDate = fromDate.AddDays(-((int)fromDate.DayOfWeek - (int)findDay));
else if (fromDate.DayOfWeek == findDay && skipSame == true)
fromDate = fromDate.AddDays(-7);
return fromDate;
}
the skipSame variable does not include the current day if it is the saem as the desired day.