Week number

2 posts, 0 answers
  1. Kjell
    Kjell avatar
    203 posts
    Member since:
    May 2011

    Posted 18 Mar 2014 Link to this post

    I'll try to get the week number from RadDatePicker SelectedDate

    <telerik:RadDatePicker ID="rdpDatum" width="0" PopupDirection="BottomRight" Runat="server">
     <Calendar UseColumnHeadersAsSelectors="False" UseRowHeadersAsSelectors="False" runat="server" />
     <DateInput style="display:none;" DisplayDateFormat="yyyy-MM-dd" runat="server" />
    </telerik:RadDatePicker>

    I found examples in the forum threads http://www.telerik.com/forums/radcalendar-weeknumber
    But have error, see attached file.
    Post is from 2010, tips on how I can get the week number?



  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 18 Mar 2014 in reply to Kjell Link to this post

    Hi Kjell,

    Please do the following modifications in your code which works fine at my end.

    VB:
    Protected Sub RadButton1_Click(sender As Object, e As System.EventArgs) Handles RadButton1.Click
        Dim dt As DateTime = rdpDatum.SelectedDate
        Dim number As Integer = GetWeekNumber(dt)
        Dim year As Integer = dt.Year
    End Sub
    Public Function GetWeekNumber(dtDate As DateTime) As Integer
        Dim ciCurr As CultureInfo = CultureInfo.CurrentCulture
        Dim weekNum As Integer = ciCurr.Calendar.GetWeekOfYear(dtDate, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday)
        Return weekNum
    End Function

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top