Question

My crystal report is NOT creating a "where clause" in it's "sql query".

In my "record selection formula" I call a formula that shifts the datetime: {@StartTime}

 ShiftDateTime ({MYLABOR.STARTED}, "GMT,0","");

***If I replace {@StartTime} with the actual StartTime field from the database then I get my "where clause" and the report is super fast.

Anyone know why that formula stops the "where clause" from being generated?

Here is my "record selection forumal":

{@StartTime} >= {?FirstPeriodStartDate}
and
{@StartTime} <= dateadd("d",14,({?FirstPeriodStartDate}))
Was it helpful?

Solution

Crystal is not adding that logic to your WHERE-clause because ShiftDateTime is a Crystal Function and NOT a valid function your database can use. Basically, Crystal doesn't know how to translate it into valid SQL. This is nearly always the case when you use Crystal functions on database fields in the record selection formula.

So what happens in this case is that Crystal leaves off the WHERE-clause logic and just gets ALL the records from the database and then applies the selection locally...which is why you're seeing such a drastic performance slow down; you're getting all records from the database regardless of their shift start time.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top