This is a migrated thread and some comments may be shown as answers.

Week number for a given date

1 Answer 110 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Alberto
Top achievements
Rank 1
Alberto asked on 27 Sep 2010, 01:39 AM
Hi Everyone,

I am trying to get an easy way to obtain the Week Number for a given date. I have found the following GetWeekNumber function but it is not the same number that RadCalendar displays.

 

public static int GetWeekNumber(DateTime dtPassed)

 

{

 

 

CultureInfo ciCurr = CultureInfo.CurrentCulture;

 

 

 

int weekNum = ciCurr.Calendar.GetWeekOfYear(dtPassed, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);

 

 

 

return weekNum;

 

}

 

 

 

Does anyone know how to retrieve the Week number display in the Rad Calendar?

also,

Does anyone know how to select a week based on a Week number  in the Rad Calendar?

 

Your response to this thread would be excellent.

 

Regards,

 

Alberto

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 27 Sep 2010, 11:21 AM
Hi Alberto,

RadCalendar by default uses CalendarWeekRule.FirstDay, that's why you get a different week number.

http://msdn.microsoft.com/en-us/library/system.globalization.calendarweekrule.aspx

Either modify your GetWeekNumber method, or make RadCalendar use CalendarWeekRule.FirstFourDayWeek like this:

http://www.telerik.com/community/forums/aspnet-ajax/calendar/2009-amp-53-weeks.aspx

Since the control does not provide an API method to select all dates from a given week, you will have to do this manually.

All the best,
Dimo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Calendar
Asked by
Alberto
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or