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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Bug? Grouping expression "between" for DateTime

Thread ID:





38564 Dec 15,2005 02:43 AM UTC Dec 15,2005 05:48 PM UTC WinForms 3
Tags: Grouping
Asked On December 15, 2005 02:43 AM UTC

The following code creates a simple filter. It selects 2 rows: ''12/13/2005'' and ''12/13/2005 2:00am'' I''m trying to select everything between ''12/13/2005 11:59pm'' and ''12/14/2005 11:59pm'' Neither of the dates above fall into my criteria. Please advice... Thanks! private void Form1_Load(object sender, System.EventArgs e) { DataTable table1 = new DataTable(); table1.Columns.Add("MyCol1", typeof(DateTime)); for (int i=10; i<=20; i++) { table1.Rows.Add(new object [] {new DateTime(2005, 12, i)}); table1.Rows.Add(new object [] {new DateTime(2005, 12, i).AddHours(2)}); } dataGrid1.DataSource = table1; gridGroupingControl1.DataSource = table1; DateTime dt1 = new DateTime(2005, 12, 14).AddMinutes(-1); DateTime dt2 = new DateTime(2005, 12, 15).AddMinutes(-1); string sGroupingExpression = string.Format("[MyCol1] between {{ {0}, {1} }}", dt1, dt2); gridGroupingControl1.BeginUpdate(); gridGroupingControl1.TableDescriptor.RecordFilters.Clear(); gridGroupingControl1.TableDescriptor.RecordFilters.Add(sGroupingExpression); gridGroupingControl1.EndUpdate(true); return; }

stanleyj [Syncfusion]
Replied On December 15, 2005 02:42 PM UTC

Hi Jeck, We do not have the support for checking the times with dates using the Between operator. A feature request is registered. Link to the feature request To handle this problem now, instead of using RecordFilters, you can subscribe to the QueryRecordMeetsFilterCriteria event and handle the testing requirement for whatever conditions you want. Here is a little sample. Best regards, Stanley

Administrator [Syncfusion]
Replied On December 15, 2005 05:33 PM UTC

Thanks! I''ll try your way of doing it. It worked fine when I used RecordFilterDescriptor object with 2 FilterCondition objects (MoreThanOrEqual, date1) and (LessThan, date2) I was building my code using the help article in SF User Guide titled "Valid Expression Syntax" It includes: Expressions may be any well-formed algebraic combination of column mapping names enclosed with brackets ([]), numerical constants and literals, and the algebraic and logical operators listed in the table below. ... between - Checks if a date field value between the two values is listed in the right-hand operand. For example, [date] between {2/25/2004, 3/2/2004} returns 1 for any record whose date field is greater or equal 2/25/2004 and less than 3/2/2004. To represent the current date, use the token TODAY. To represent DateTime.MinValue, leave the first argument empty. To represent DateTime.MaxValue, leave the second argument empty. The same article is titled "Algebra supported in Expressions/Filters" in Studio 4 Beta So clearly there is "some" kind of support of it :)

Administrator [Syncfusion]
Replied On December 15, 2005 05:48 PM UTC

It supports only whole dates. The current code that does the evaluation for the BETWEEN operator truncates the time portion of the DateTime object.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon