How do I find the week number in a month
I need to find week number in a month. It could be 4 or 5 weeks in a month (depending on the calendar) and I need to find the week number based on the current date. Note : (Day)/7 would not work since Week 1 or Week 4 would be assumed to have 7 days which is not always the case.
Set the count to 1, and enumerate every day of a month. Add to count by 1 for each sunday except the first day. After the enumeration, the count is the number of weeks in that month.
just do like this
DateTime date =DateTime.Now; int weekOfMonth=(date.Day + ((int)date.DayOfWeek)) / 7 + 1;
calculation based on Malaysia time is (today number is 13 + day of week is 2) divided by
7and then add
oneto result so result would be