Problem : How do I get number of week per month for the particular date?
Solution :
// Get Num of Week Per Month
public static int GetWeekInMonth(DateTime date)
{
DateTime tempdate = date.AddDays(-date.Day + 1);
CultureInfo ciCurr = CultureInfo.CurrentCulture;
int weekNumStart = ciCurr.Calendar.GetWeekOfYear(tempdate, CalendarWeekRule.FirstFourDayWeek, ciCurr.DateTimeFormat.FirstDayOfWeek);
int weekNum = ciCurr.Calendar.GetWeekOfYear(date, CalendarWeekRule.FirstFourDayWeek, ciCurr.DateTimeFormat.FirstDayOfWeek);
return weekNum - weekNumStart + 1;
}
Reference :
using System.Globalization;
C# Get Week Number In Month
Posted by Unknown at 8/30/2013 11:40:00 am
Labels: ASP.net C#, C#
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment