Generally, database-specific syntax isn’t available via the Silverstripe ORM, since it needs to support multiple databases. So, a couple of choices:
You can use SQLSelect or similar to build the query in a more manual way:
You can also use search modifiers to build your query within the ORM:
//Example only - You can use fancier means to build the start / end (eg. DateTime, php date, etc)
$year = 2021;
$start = $year . '/01/01';
$end = $year . '/12/31';
BlogPost::get()->filter([
'ParentID' => $blog->ID,
'Categories.Title' => $kat,
'PublishDate:GreaterThanOrEqual' => $start,
'PublishDate:LessThanOrEqual' => $end
]);
Now, the one thing I’m not sure about without actually testing it is whether you can use the methods on the DBDate field directly in the query (sorry, I should, but it’s been a while!)
So, try the following before you get too carried away!
BlogPost::get()->filter([
'ParentID' => $blog->ID,
'Categories.Title' => $kat,
'PublishDate.Year' => $year
]);
If that doesn’t fly, then you could get fancier and add a method to the BlogPost class with an extension and filter against that… but I’ll wait to see what happens with the above first!