Unable To Filter By Date (Comparing Dates Issue)

Stimulsoft Reports.JS discussion
Post Reply
markb
Posts: 17
Joined: Fri Jul 07, 2017 10:56 am

Unable To Filter By Date (Comparing Dates Issue)

Post 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).
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

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

Post 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.
Post Reply