Calendar control picker is Date, while field in the db is Datetime, what to do?

STMO63

New Member
I have a GridView that should be populated according to a selected date, so I made the use of the \[code\]Calendar control\[/code\].The problem
  • Unfortunately the selected date in the \[code\]Calendar\[/code\] is in the format: \[code\]dd-MM-yyy\[/code\]
    example 2013-02-15
  • while the \[code\]date field\[/code\] in the Database is of type \[code\]datetime\[/code\] meaning: \[code\]dd-MM-yyyy HH:mm:SS.ms\[/code\]
    example 2013-02-15 09:02:03.253
So there will be no result since the Calendar control and the Database field are of different types.
What i tried\[code\]SqlDataSource1.SelectCommand = "Select * from table1 where start_date Like '% " & calendar1.SelectedDate.Date & " %' "\[/code\]As you can see i worked the sqldatasource in code behind and i made the use of \[code\]Like\[/code\] But even with the use of \[code\]Like\[/code\] no results show due to Database having not only date but time too.I was also thinking to change the sql query itself, and precisely the field \[code\]start_date\[/code\], to omit the time (HH:mm:SS.ms) but is it possible to do so?
 
Top