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

help with calendar control and time picker

3 Answers 48 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 05 Jun 2009, 02:59 PM
Hi
This may sound stupid but i need to add a date and time to a database and am using the calendar control and the time picker as the time slots we are using are at 2 hr intervals ho do i pull the date out of the calender and the time out of the time picker and put the 2 together?

Many thanks

3 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 08 Jun 2009, 06:29 AM
Hi Kevin,

Try the code below to combine the Date and Time values in to a single DateTime object.

ASPX:
 
<telerik:RadCalendar ID="RadCalendar1" runat="server" EnableMultiSelect="False">  
</telerik:RadCalendar> 
<telerik:RadTimePicker ID="RadTimePicker1" runat="server">  
</telerik:RadTimePicker> 

CS:
 
protected void Button1_Click(object sender, EventArgs e)  
{  
    string[] time = RadTimePicker1.SelectedDate.ToString().Trim().Split(' ');  
    string[] date = RadCalendar1.SelectedDate.ToString().Trim().Split(' ');  
    string datetime = date[0] + " " + time[1] + time[2];  
    DateTime DateTimeValue = DateTime.Parse(datetime);  
    Response.Write(DateTimeValue.ToString());  
    // Update database with DateTimeValue.  

-Princy.
0
Kevin
Top achievements
Rank 1
answered on 09 Jun 2009, 08:34 AM
thanks that has sorted my issue
0
Larry
Top achievements
Rank 1
answered on 24 May 2012, 04:35 PM
DateTime finalDateTime = DateTime.Parse(Strings.Format(PrefDate.SelectedDate, "Short Date") + " " + Strings.Format(PreTime.SelectedDate, "Short Time"));
Tags
Calendar
Asked by
Kevin
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Kevin
Top achievements
Rank 1
Larry
Top achievements
Rank 1
Share this question
or