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

RadDatePicker - get the Year part from the SelectedDate value

2 Answers 192 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Ida
Top achievements
Rank 1
Ida asked on 02 Oct 2013, 11:28 AM
Hi,

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

Thanks, Ida

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 03 Oct 2013, 03:02 AM
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.
0
Ida
Top achievements
Rank 1
answered on 03 Oct 2013, 10:32 AM
Many thanks Shinu!

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

Ida
Tags
Calendar
Asked by
Ida
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Ida
Top achievements
Rank 1
Share this question
or