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);
}
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);
}