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

How to get date and time components

2 Answers 79 Views
TimePicker and TimeSelector
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Michael
Top achievements
Rank 1
Michael asked on 17 Dec 2012, 06:23 AM
I am attempting to do the following:

EventToPost.BeginsDateTime = radDatePickerBegin.Date + radTimePickerBegin.TimeOfDay;

 
Date, however, is not a property of the radDatePicker and neither is TimeOfDay a property of radTimePicker. It seems that they both will return only .Value which in both cases is a DateTime. This means that to set the BeginsDateTime property in EventToPost, I need to do some messy conversion and extraction of date and time values respectively so that I can add the time component to the date component.

What am I missing here?

Michael

2 Answers, 1 is accepted

Sort by
0
Michael
Top achievements
Rank 1
answered on 17 Dec 2012, 07:33 AM
It looks like I've figured out a way to solve the problem.

  TimeSpan EndsDateTimeSpan = (TimeSpan)(radTimePickerEnd.Value - radDatePickerEnd.Value);
  EventToPost.EndsDateTime = (DateTime)(radDatePickerEnd.Value - EndsDateTimeSpan);

radDatePicker seems to remove the time component (as expected) while radTimePicker does not (not intuitive, but I understand why). So the solution is to subtract the value of radDatePicker from that of radTimePicker which yields a TimeSpan. This in turn can be added to the radDatePicker.Value to obtain the combined Date and Time values.

It would be very handy to be able to directly access the time value from the radTimePIcker as a TimeSpan which is what I was expecting.

Michael
0
Deyan
Telerik team
answered on 17 Dec 2012, 11:49 AM
Hello Michael,

RadDatePicker and RadTimePicker both work with DateTime values. The RadTimeSpanPicker control works with TimeSpan values.

Let me know if you have further questions or need assistance.

Greetings,
Deyan
the Telerik team
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
Tags
TimePicker and TimeSelector
Asked by
Michael
Top achievements
Rank 1
Answers by
Michael
Top achievements
Rank 1
Deyan
Telerik team
Share this question
or