How do we add 15 days to the current Date which will not cross the month
and resultant Date will never be Sunday? If it is Sunday make it Saturday?
Example > If Current Date is 17/08/2010 (DD/MM/YYYY)
Then Resultant Date is 31/08/2010 (DD/MM/YYYY) [Donot Cross the Current Month.]
Also 31/08/2010 would never be Sunday.
If it is Sunday make it 30/08/2010 (Saturday). [Date is not Sunday.]
Loading
Deepak BhatiaPosted Aug 5, 2010, 2:26 AM
Deepak BhatiaPosted Aug 5, 2010, 2:25 AM
I have sorted down your problem. Try this code
DateTime dateToday = DateTime.Now;
DateTime After15Day = dateToday.AddDays(15);
while (After15Day.Month != dateToday.Month)
{
After15Day.AddDays(-1);
}
if (After15Day.DayOfWeek == DayOfWeek.Sunday)
After15Day.AddDays(-1);