Week number for a given date

2 posts, 0 answers
  1. Alberto
    Alberto avatar
    7 posts
    Member since:
    Jul 2008

    Posted 26 Sep 2010 Link to this post

    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?


    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.





  2. Dimo
    Dimo avatar
    8486 posts

    Posted 27 Sep 2010 Link to this post

    Hi Alberto,

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


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


    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,
    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
Back to Top