RadDatePicker - get the Year part from the SelectedDate value

3 posts, 0 answers
  1. Ida
    Ida avatar
    55 posts
    Member since:
    Mar 2013

    Posted 02 Oct 2013 Link to this post

    Hi,

    Is it possible to extract the Year (YYYY) part of the SelectedDate value, when using the RadDatePicker control?

    Thanks, Ida
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 02 Oct 2013 Link to this post

    Hi Ida,

    Please try the following code snippet that I tried to access the Year part of the SelectedDate in RadDatePicker.

    ASPX:
    <telerik:RadDatePicker ID="RadDatePicker1" runat="server" AutoPostBack="true" OnSelectedDateChanged="RadDatePicker1_SelectedDateChanged">
    </telerik:RadDatePicker>

    C#:
    protected void RadDatePicker1_SelectedDateChanged(object sender, Telerik.Web.UI.Calendar.SelectedDateChangedEventArgs e)
    {
        DateTime date = RadDatePicker1.SelectedDate.Value;
        int year=date.Year;
    }

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ida
    Ida avatar
    55 posts
    Member since:
    Mar 2013

    Posted 03 Oct 2013 Link to this post

    Many thanks Shinu!

    That worked great! Was able to adapt it for VB.NET.

    Ida
Back to Top