I've a problem here. I need to get a quarter of the year without the past quarter. F.e:
In my database I have a field created_at
, which saves the timestamp of service created. I need to not involve those services, which was made in the past quarter. How should I do that?
I'm trying to write a SQL function like this to not involve those services, which was made in the past quarter:
$services= Service::find()
->where([
'client_service.created' => function ($model) {
return ceil(date('n') / 3) - 4;
But I guess I'm wrong. Thanks for any help.
Edited:
$services= Service::find()
->select(['client.id as client_id'])
->joinWith('client')
->where([
'service.type' => Service::TYPE,
'service.is_archived' => Service::ARCHIVED,])
->andWhere([
'or',
['client_service.status' => ClientService::STATUS_NEGATIVE],
[client_service.created' => function ($model) {
return ceil(date('n') / 3) - 4;]