We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

RecordFilterDescriptor filter expression help for datetime comparison

I have having a problem adding a date filter to the filter expression. The first filter expression below works. However, when I add a date filter to the expression, I am not getting any results although the data is present. The filter i am having problem with is the [WeekID]=?


filterExpr = "[TitleID]=9100 AND [Length]=30 AND [Rate]=0.0000 AND [RevenueTypeID]=1 AND [InventoryTypeID]=2"


filterExpr = "[TitleID]=9100 AND [Length]=30 AND [Rate]=0.0000 AND [RevenueTypeID]=1 AND [InventoryTypeID]=2 AND [WeekID] = #6/26/2006#"

RecordFilterDescriptor rfd = new RecordFilterDescriptor(filterExpr);
this.gridGroupingControl2.TableDescriptor.RecordFilters.Add(rfd);


In the actual dataset, the field is a sql datetime and the value is shown in the.net dataset visualizer as -> '6/26/2006 12:00:00 AM'

How do I compare datetime values?


3 Replies

AD Administrator Syncfusion Team December 13, 2006 09:56 AM UTC

Hi James,

You can filter the Dates by using the following code snippet. For example, to filter to particular dates please follow the code snippet below.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
this.gridGroupingControl1.TableDescriptor.RecordFilters.Add("Column3",FilterCompareOperator.Equals,"12/13/2006");
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

To Filter dates greater than some specific date, please follow the code snippet below
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
tableCellIdentity.Table.TableDescriptor.RecordFilters.Add("DateTimeColumn",FilterCompareOperator.GreaterThan,"7/25/2006");
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

In some cases, if you want to filter between two dates, then you can use between operator
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
tableCellIdentity.Table.TableDescriptor.RecordFilters.Add(“[Col2] between {7/25/2006,9/20/2007}”);
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Kindly let us know if you need any further assistance.
Have a nice day.

Best regards,
Madhan


JB James Blibo December 13, 2006 03:42 PM UTC

This is still not working!

No matter how I enter the enter '6/26/2006', DateTime.Parse('6/26/2006'), or '6/5/2007 12:00:00 AM', the FilterDescriptor is not working.

fc = new FilterCondition(FilterCompareOperator.Equals, "6/5/2007 12:00:00 AM");


fc = new FilterCondition(FilterCompareOperator.Equals, "6/5/2007");


fc = new FilterCondition(FilterCompareOperator.Equals, #6/5/2007#);

In the dataTable itself, the field is a datetime and the value in the visual studio visualizer is shown in the format '6/5/2007 12:00:00 AM'


JB James Blibo December 13, 2006 03:46 PM UTC

Never mind, i made a stupid mistake :(

Loader.
Live Chat Icon For mobile
Up arrow icon