Can't subtract days from a date Please Help
Hello,
I'm trying to get the week ending and month ending dates of approximately 4 weeks past today's date. I have written some code that gets the date for last sunday, but does not go past that. If anyone can help me out I would appreciate it. Here is the code:
TimeSpan oneDay = new TimeSpan(1,0,0);
Calendar calendar = info.Calendar;
DateTime dtNow = DateTime.Today;
dt = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day, calendar);
int count = 0;
dt.Month);
int x, y;
for (x = 0; x <= 3; x++)
{
while(!dt.DayOfWeek.Equals(DayOfWeek.Sunday) && (dt.Day != eom))
{
dt = dt.Subtract(oneDay);
eom = DateTime.DaysInMonth(dt.Year, dt.Month);
}
endingDatesList += dt.ToShortDateString() + ", ";
for (y = 0; y <= 25; y++)
{
dt = dt.Subtract(oneDay);
}
}
Thanks!
*******(*)*******
__________________
*******(*)*******
|