我有一张桌子attendace
出席了不同的日期。现在我想参加上个月的最后一次参加。我用过这个:
$attt = Attendance::find()
->select('daytime')
->orderBy(['daytime' => SORT_DESC])
->one();
答案 0 :(得分:2)
尝试设置
$yourMonth = date('m') -1;
$attt = Attendance::find()->select('daytime')
->where(" MONTH( my_date_field) = $yourMonth ")
->orderBy(['daytime'=>SORT_DESC])->one();