rounding the SelectedValue to the nearest minute

2 posts, 0 answers
  1. Elneilo
    Elneilo avatar
    6 posts
    Member since:
    Apr 2011

    Posted 22 Nov 2011 Link to this post

    I'm new to the RadDateTimePicker and I'm wondering if the control can allow me to
    round the SelectedValue to the minute (to effectively zero-out the seconds and milliseconds portion).

    <telerik:RadDateTimePicker SelectedValue="{Binding TheVisitDateTime, Mode=TwoWay}"/>

    I need it for calling a stored procedure with a SMALLDATETIME Parameter (which I'm not allowed to change).
    So before I consider writing a ValueConverter for this, I need to know if the RadDateTimePicker control exposes a property for rounding to the minute ?

    Right now the milliseconds is being passed to the stored procedure which is causing a conversion error.
    (because the @dVisitDateTime is SMALLDATETIME data type).

    exec schma.CompleteClientVisit @iVisitID = 1, @dVisitDateTime = '2011-11-22 15:47:10.25039', ...other params...
    Msg 8114, Level 16, State 1, Procedure CompleteClientVisit, Line 0
    Error converting data type varchar to smalldatetime.

    My goal is to call the stored procedure such as below to avoid the conversion error.
    exec schma.CompleteClientVisit @iVisitID = 1, @dVisitDateTime = '2011-11-22 15:47:00', ...other params...
  2. Konstantina
    Konstantina avatar
    2332 posts

    Posted 25 Nov 2011 Link to this post

    Hello Elneilo,

    I am afraid, there is no build in property in the DateTimePicker for achieving this. You are going to have to create a converter which will return time in the needed format.

    Kind regards,
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Back to Top