KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Datastore - Counting Records Before Date #1410

Closed Steph opened this topic on on Apr 27, 2020 - 4 comments

Steph commented on Apr 27, 2020

Hi All,

I just wanted to check if this syntax is right to count the number of records before a date:

$this->dataStore('courseNumbers')->where('Date','<','2020-04-29')->count()

... it always seems to return 0. Date is a normal SQL date field.

Thanks.

KoolReport commented on Apr 27, 2020

Hi Stepth,

You use the filter() method instead:

$this->dataStore('courseNumbers')->filter('Date','<','2020-04-29')->count()

Let me know if it works.

Steph commented on Apr 27, 2020

Thank you it does, bit confused about the difference between 'where' and 'filter' - can you explain?

KoolReport commented on Apr 28, 2020

The filter() function is universal for filtering while where() only deal with equal comparison. Sorry that it sounds a little confusing, I understand we are working with SQL so we tend to understand WHERE statement seems dealing with all kinds of filtering. I will send your topic to dev.team since it contains a good suggestion for method naming for us.

Steph commented on Apr 28, 2020

Thank's for your help - you're absolutely right I assumed 'where' in an SQL context.

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
solved

None