2
Answers

DataView RowFilter not working

I am working on a simple database c# program. Using MS Access as end database. I have a form with datagridview, using Dataview as Datasource.
 
When I try to use DataView.Row filter, All operators (<, >, <=, >=) are working except = (equal) not working. My column datatype is DateTime. That part of the code is shown below.
 
Advance thanks, Please help.
  1. string Today = DateTime.Now.ToString();  
  2. string FilterCmd = string.Format("ColumnName = #{0}#", Today);
Answers (2)
0
Amit Gupta

Amit Gupta

NA 16.5k 25.6k 7y
Hey
 
I think the problem is with the date format, make sure your db date format matches the DateTime.Now eg. MM/dd/yyyy
 
Refer
https://stackoverflow.com/questions/3584571/compare-dates-in-dataview-rowfilter 
Accepted
0
Jothish Kumar

Jothish Kumar

NA 201 3.3k 7y
Hi,
 
check the below link where the date format for Dataview.Row filter is given.
 
https://forums.asp.net/t/1519078.aspx?How+to+format+a+Date+Field+in+DataView+RowFilter+to+consider+Date+only+Not+Time
 
Thank you