Could somebody please help me figure out how to make a ORM sql query on a dataobject that returns the count of dataobjects created today. Cant figure it out in the new SS3 ORM.
We've moved the forum!
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
Found a solution that seems to work:
DB::query("SELECT count(*) FROM Invoice WHERE Created BETWEEN '".date('Y-m-d')." 00:00:00' AND '".date('Y-m-d')." 23:59:59'")->value()
And that seems to be the right way
$count = Invoice::get()->filter(
array(
'Created:GreaterThan' => date('Y-m-d').' 00:00:00',
'Created:LessThan' => date('Y-m-d').' 23:59:59'
)
)->count();