Page 1 of 1

Unable To Filter By Date (Comparing Dates Issue)

Posted: Fri Jul 07, 2017 11:43 am
by markb
I would like to add an expression to the DataBand filter, or even just as an expression, that states:

Code: Select all

{Users.ExpiryDate > Today}
where Users.ExpiryDate is a datetime DataTable field filled with various dates.

When using the Designer, I look at the Data Sources, pick the Users table, ExpiryDate is not showing as a datetime field but alpha [abc], probably due to the conversion to JSON when loading.
So then I presumed that I would need to change the above expression to

Code: Select all

{Convert.ToDateTime(Users.ExpiryDate) > Today}
to make sure it was comparing two dates. Still didn't fix the problem.
So I then converted the field to a date using the following expression:

Code: Select all

{DateSerial(TryParseLong(Substring(Users.ExpiryDate.ToString("yyyy-MM-dd"),0,4)),TryParseLong(Substring(Users.ExpiryDate.ToString("yyyy-MM-dd"),5,2)), TryParseLong(Substring(Users.ExpiryDate.ToString("yyyy-MM-dd"),8,2))) > Today}
This was the only way I could compare the two dates, and actually get the DataBand filter to work.

1. Where is the "Check" button in the Filter DataBand Expression screen (to validate expressions)? Also why do expressions need {} to surround but filter expressions dont need {}.
2. Why cannot compare Convert.ToDateTime(Users.ExpiryDate) to the function Today? It seems that Users.ExpiryDate cannot be converted into a date, except by using DateSerial.
3. Surely the DateSerial() function API reference should say DateSerial(year, month, day) rather than DateSerial(int64, int64, int64) it would be more readable (same applies to other functions).

Re: Unable To Filter By Date (Comparing Dates Issue)

Posted: Tue Jul 11, 2017 3:04 pm
by Alex K.
Hello,

> 1. Where is the "Check" button in the Filter DataBand Expression screen (to validate expressions)? Also why do expressions need {} to surround but filter expressions dont need {}.

The Check feature is not available separately for the filter, only for all report.

> 2. Why cannot compare Convert.ToDateTime(Users.ExpiryDate) to the function Today? It seems that Users.ExpiryDate cannot be converted into a date, except by using DateSerial.

Please send us a simple report with test data which reproduces issues for analysis.

> 3. Surely the DateSerial() function API reference should say DateSerial(year, month, day) rather than DateSerial(int64, int64, int64) it would be more readable (same applies to other functions).

We will have discussed this issue. We will let you know about the result.

Thank you.