LJames 0 Newbie Poster

I need to fill my gridview with just the records that fall in the date range. The dates come from two calendar controls. If I choose dates where the day is in single figures I get a return, if I choose higher value days I get an error - "Cannot perform '<' operation on System.DateTime and System.String." I am guessing it is something to do with the date format but I can't work out how to reformat the date in the expression, it just falls over whatever I use.

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
    ConnectionString="<%$ ConnectionStrings:dbprojlibConnectionString3 %>" 
    SelectCommand="SELECT * FROM [tblProjects] "
     FilterExpression="(StartDate > ' {0} ' AND StartDate < ' {1} ') " >
                 <FilterParameters>
                    <asp:ControlParameter Name="FirstDate" ControlId="calStartDate" PropertyName="SelectedDate" Type="datetime"/>
                    <asp:ControlParameter Name="LastDate" ControlId="calLastDate" PropertyName="SelectedDate" Type="datetime"/>
                </FilterParameters>  
                
</asp:SqlDataSource>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.