15,921,884 members
See more:
Hi Team,
Required functionality is to get the return week number of a given date.
Supposed `8th March 2010` is the given date then it should return "2" as 2nd week. I have implemented a below method which return week number of the year, whereas requirement is return week no of the current month.
Could any body help me out from this scenario.
C#
```public static int GetWeekNumber(DateTime dtPassed)
{
CultureInfo ciCurr = CultureInfo.CurrentCulture;
int weekNum = ciCurr.Calendar.GetWeekOfYear(dtPassed, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);
return weekNum;
}```

Tarun Singh. :laugh:

[Corrected broken formatting]
Posted
Updated 8-Mar-10 3:41am
v2

## Solution 1

1. Check the day of the week for the 1st of given dates month
2. Take just the "day" value of given date
3. Based on point 1 & 2 and the factor 7 (days in a week), you can get it.
Right?

Though simpler approach would be:
1. Check the WeekOfYear of 1st of given date's month = x
2. Check the WeekOfYear of the given date = y
3. Week Number of current month = y-x+1

Hope that solves it all!

v3