Unable To Filter By Date (Comparing Dates Issue)
Posted: Fri Jul 07, 2017 11:43 am
I would like to add an expression to the DataBand filter, or even just as an expression, that states:
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 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:
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).
Code: Select all
{Users.ExpiryDate > Today}
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}
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}
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).