Display datetime between two dates

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi there,
I can not think of a way to display each day of the week between two dates.
I have the following function which returns a date. How can I display those
days? Or how can I put each of the days in an array.

Thansk so much for putting me on the right track. Chris

DateTime dt = DateTime.Today;
DateTime nextWednesday = GetNextOccurenceOfDay(dt, DayOfWeek.Wednesday);
public DateTime GetNextOccurenceOfDay(DateTime value, DayOfWeek dayOfWeek)
{
int daysToAdd = dayOfWeek - value.DayOfWeek;
if(daysToAdd < 1)
{
daysToAdd += 7;
}
return value.AddDays(daysToAdd);
}
 
Sorry guys I wasn't thinking It can not get easier then this.

LblThu.Text = nextWednesday.AddDays(-6).ToString("dd/MM/yyyy");

Thanks again

Chris
 
Back
Top