Click here to Skip to main content
15,666,844 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Good day

I have one table in sql database one field is [date] it's type is date, for example (id,[date],[event])
using C# windows form I need to add dateTimePicker and DataGrid
datagrid is filling by db table

I need way to filter data in grid by introduction special date by dataTimePicker.

Thanks for help

Hi friend,

this may help you...

select * from Complaints where Convert(smalldatetime,Convert(varchar(10),Complaint_Date,103),103) between'" + Convert.ToDateTime(dtpFrom.Value).ToString("MM/dd/yyyy") + "' and '" + Convert.ToDateTime(dtpTo.Value).ToString("MM/dd/yyyy") + "'", cnn);

Where Complains is my database table and Complaint_date is the DateTime Column...
According to ur requirement please change the query...
Here i m filtering the gridview by two dates.

Where dtpFrom,dtpTo are date time pickers...
and set in front end date time picker's custom format as "dd/MM/yyyy".
Share this answer
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