EX day format : MM/DD/YYYY start day : "4 - 1 - 2013 " End day : " 5 - 2 - 2013 "
I WANT COUNT ALL SUNDAY IN TO 4-1-2013 FROM 5 /2 / 2013
DateTime start = Convert.ToDateTime("2013-04-01"); DateTime end = Convert.ToDateTime("2013-05-02"); int count = 0; for(DateTime d = start.Date; d < end.Date; d = d.AddDays(1)) { if (d.DayOfWeek == DaysOfWeek.Sunday) { count += 1; } }
thank very much