I want to calculate the number of weeks within a month.

The first week of January 2014 starting from the first Monday is the 6th. So, January has 4 weeks. The first week of March 2014 starting from the first Monday is the 3rd. So, March has 5 weeks.

I want to know how many weeks there are in a month counting from the first Monday, not the first day.

How do I do this?

I have this code but it is used to get week number of the month for specific dates.

```
public int GetWeekNumberOfMonth(DateTime date)
{
date = date.Date;
DateTime firstMonthDay = new DateTime(date.Year, date.Month, 1);
DateTime firstMonthMonday = firstMonthDay.AddDays((DayOfWeek.Monday + 7 - firstMonthDay.DayOfWeek) % 7);
if (firstMonthMonday > date)
{
firstMonthDay = firstMonthDay.AddMonths(-1);
firstMonthMonday = firstMonthDay.AddDays((DayOfWeek.Monday + 7 - firstMonthDay.DayOfWeek) % 7);
}
return (date - firstMonthMonday).Days / 7 + 1;
}
```

Try this:

Get the number of days in the current month, and find the first day. For each day in the month, see if the day is a Monday, if so, increment the value.

You can use it like this with the current date:

Output:4or with any month you choose: