| Author: Abhishek Arya 16 Feb 2006 | Member Level: Diamond | Rating:  Points: 2 |
use this code
private int NumMondays(string month_name, string year_name) { int i; int num_mondays; System.DateTime test_date; int orig_month; test_date = System.Convert.ToDateTime(month_name + " 1, " + year_name); if (Weekday(test_date) == vbMonday) { } else if (Weekday(test_date) == vbTuesday) { test_date = DateAdd("d", 6, test_date); } else if (Weekday(test_date) == vbWednesday) { test_date = DateAdd("d", 5, test_date); } else if (Weekday(test_date) == vbThursday) { test_date = DateAdd("d", 4, test_date); } else if (Weekday(test_date) == vbFriday) { test_date = DateAdd("d", 3, test_date); } else if (Weekday(test_date) == vbSaturday) { test_date = DateAdd("d", 2, test_date); } else if (Weekday(test_date) == vbSunday) { test_date = DateAdd("d", 1, test_date); } orig_month = Month(test_date); do { num_mondays = num_mondays + 1; test_date = DateAdd("ww", 1, test_date); } while ((Month(test_date) == orig_month)); NumMondays = num_mondays; }
|