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

Timepicker ignoring dateinput dateformat

3 Answers 83 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Simon
Top achievements
Rank 1
Simon asked on 22 Aug 2011, 02:52 PM
I have the folloing code for a RadTimePicker but for some reason in my page behind when I submit a query to the database with tpEndTime formatted as a string it is inputting the date and time in to the database column, not just the time. The db table column that has the issue is set to nvarchar and there are no formatting calls on the field before the insert.

Dim dEndTime As String = tpEndTime.SelectedDate

So instead of 18:00 my database is showing 8/22/2011 18:00:00 PM

<telerik:RadTimePicker ID="tpEndTime" runat="server" Skin="Vista">
                <DateInput DateFormat="HH:mm" DisplayDateFormat="HH:mm" runat="server"></DateInput>
                <TimeView ShowHeader="true" HeaderText="End Time" Interval="00:15:00" Columns="4" StartTime="08:00:00" EndTime="20:00:00" TimeFormat="HH:mm" runat="server"></TimeView>
</telerik:RadTimePicker>

I am using the latest version of the ASP.net AJAX controls

3 Answers, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 25 Aug 2011, 08:27 AM
Hello Simon,

This is expected, since the RadDateInput's value is always of DateTime type, so you always get a full DateTime object from it, it is only the format string that differs. If you would like to keep only the time in the database, you could first use the ToShortTimeString() method of the DateTime class to get only the needed part of the value.

Best wishes,
Tsvetina
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
-DJ-
Top achievements
Rank 1
answered on 07 Nov 2012, 09:44 PM
Hi,

That sure is annoying. It is a timepicker after all, not a datetimepicker.
So if you store only the time in db, in a time field and not a datetimefield, you again have to go through some idiodic steps to create a fake date value to be able to bind the value to the time picker.

Instead of actually being able to bind a time value to a time picker.

Seriously...
It's a TIME picker.
Or so it's called anyway.

-DJ-
0
Maria Ilieva
Telerik team
answered on 13 Nov 2012, 09:02 AM
Hi Daniel,

Note that no matter if RadDatePicker or RadTimePicker control is used there are composite controls which includes RadDateInput control. And as we previously state the RadDateInput value is always of DateTime type. Therefore the only possibility you have is to convert the Time part to string as per your needs.

Regards,
Maria Ilieva
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Calendar
Asked by
Simon
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
-DJ-
Top achievements
Rank 1
Maria Ilieva
Telerik team
Share this question
or