Click here to Skip to main content
15,746,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello all,

By any chance, does anyone have a code to filter by date and time using sql server 2012 and, this information will be display on a datagridview and I will be using to datetimepickers to filter the date. The information is saved in the db with datetime and is saved like this "07/25/2017 2:32.00"

Any help will be very much appreciated.


What I have tried:

I have tried different codes but no success. I'm just wondering if somebody has any idea or a code that I can try.
Updated 27-Jul-17 23:49pm
David_Wimbley 25-Jul-17 21:54pm    
We don't know enough about how you are getting the data. Are you using entity framework? scripts from code?
Karthik_Mahalingam 26-Jul-17 1:10am    
Use Improve question to add more info to the question.

1 solution

you can convert your datetime column and then filter your records.
select * from tablename
WHERE  CONVERT(VARCHAR,[Datecolumn],103) <= CONVERT(VARCHAR,@param,103)
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900