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

RadDatePicker value

1 Answer 129 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Darryl
Top achievements
Rank 1
Darryl asked on 25 Oct 2011, 07:06 PM
Hello,

I'm having problems getting the value of RadDatePicker and using that value as an input for my SQL statement.  The query works if I replace the variables to normal values.

Here is my code snippet.

<asp:SqlDataSource ID="SqlDataSource" runat="server"
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
        ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>"
        SelectCommand="SELECT column, column, column, column, column
FROM table A, table B
WHERE (A.ACCEPTANCE_DATE >= TO_DATE(:fromDate, 'dd-mon-yyyy'))
AND (A.ACCEPTANCE_DATE <= TO_DATE(:toDate, 'dd-mon-yyyy'))
AND column = column
AND (column LIKE 'A')
ORDER BY column, column">
         
        <SelectParameters>
            <asp:ControlParameter ControlID="radDatePickerFrom" Name="fromDate" />
            <asp:ControlParameter ControlID="radDatePickerTo" Name="toDate" />
        </SelectParameters>
   </asp:SqlDataSource>

1 Answer, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 28 Oct 2011, 09:51 AM
Hello Darryl,

You should use the same format when parsing the date as the DataFormat used in the DateInput.
Currently you are using "dd-mon-yyyy" which means that the TO_DATE expects date like: "28 Oct. 2011" However, your datepicker could give the date like: "10/28/2011" if you used the "dd/MM/yyy" format for it.
Make sure that you use the same format for the DateInput of the Picker and for your sql statement.
Check this help resources:
http://www.telerik.com/help/aspnet-ajax/input-dateinput-formatting-dates.html
http://www.techonthenet.com/oracle/functions/to_date.php

All the best,
Vasil
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
Darryl
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Share this question
or