Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > DatePicker > The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range?

Answered The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range?

Feed from this thread
  • islam avatar

    Posted on Sep 12, 2011 (permalink)

    hi all,
    i have an application which i use a RadDatePicker inside and the selected date binds a database field,
    now when i set the selected date to a very old one or  far in the future and then when i try to save the data to the domain service the server throws an exception "The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range".

    my code looks like this:
    <Telerik:RadDatePicker Grid.Row="1" Grid.Column="1" Height="22" SelectedDate="{Binding ToDate,Mode=TwoWay,NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnNotifyDataErrors=True,ValidatesOnExceptions=True}" IsEnabled="{Binding IsDatePickerEnabled}"/>  

    am i missing somthing ?
    thanks in advance.

    Reply

  • Answer Konstantina Konstantina admin's avatar

    Posted on Sep 20, 2011 (permalink)

    Hello Islam,

    DateTime supports 1753/1/1 to eternity (9999/12/31), while DateTime2 support 0001/1/1 through eternity. The DateTime2 range is the one that the DateTimePicker supports.
    So what you need to do is check for the year of the date - if it's before 1753, you need to change it to something after 1753 in order for the DateTime column in SQL Server to handle it.

    Hope this helps.

    Regards,
    Konstantina
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

    Reply

  • islam avatar

    Posted on Sep 20, 2011 (permalink)

    Thanks Konstantina, yes that was the problem so i changed the datetime type in the database to datetime2 and it worked.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > DatePicker > The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range?
Related resources for "The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range?"

Silverlight DatePicker Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]