I want to filter the gridview
by comparing a datetime column of type datetime
in sql server with a date textbox.
The datetime column in sql server is being stored/displayed (as default) in the yyyy-mm-dd hh:mm:ss.sss format.
However the date textbox is in the format dd/mm/yyyy.
<asp:TextBox ID="date_tb" runat="server" TextMode="Date"></asp:TextBox>
I tried using
FilterExpression="CONVERT(VARCHAR, [ScheduledDateTime], 105) LIKE '%{0}%'">
but it didn't work.
FilterExpression="CONVERT([ScheduledDateTime], 'System.String', 105) LIKE '%{0}%'">
also did not work.
I then tried using
SelectCommand="SELECT [ScheduledDateTime], CONVERT(VARCHAR, [ScheduledDateTime], 105) as d ... FROM table1
FilterExpression="d LIKE '%{0}%'">
but it didn't work as well.
edit:
I have changed the ControlParameter
into <asp:ControlParameter Name="ScheduledDateTime" ControlID="date_tb" PropertyName="Text" type="DateTime"/>
so I no longer have to be concerned about the date format.
Although now there is a problem to comparing date
with datetime
.