Timepicker ignoring dateinput dateformat

4 posts, 0 answers
  1. Simon
    Simon avatar
    3 posts
    Member since:
    Aug 2011

    Posted 22 Aug 2011 Link to this post

    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>

    I am using the latest version of the ASP.net AJAX controls
  2. Tsvetina
    Tsvetina avatar
    1861 posts

    Posted 25 Aug 2011 Link to this post

    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,
    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 >>

  3. DevCraft R3 2016 release webinar banner
  4. -DJ-
    -DJ- avatar
    263 posts
    Member since:
    Oct 2004

    Posted 07 Nov 2012 Link to this post


    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.

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

  5. Maria Ilieva
    Maria Ilieva avatar
    4017 posts

    Posted 13 Nov 2012 Link to this post

    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.

    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.
Back to Top