How to choose the current record in Yii2?

Hello, there is a table Bet, try to make the selection of records today in the field date. It is of type timestamp, that is, contains both date and time. Cut off time to get thanks to the CAST, but for some reason the request still does not output anything.

$bets = BetList::find()
 ->select('CAST(date AS DATE) AS date')
 ->where('order_id = :order_id', [':order_id' => $order->id])
 ->andWhere('date = :today', [':today' => date("Y-m-d")])

And if separately to withdraw $bets->date and date("Y-m-d"), they will be absolutely identical.
What could be the problem? Thanks in advance.
June 8th 19 at 16:48
2 answers
June 8th 19 at 16:50
you then cited the resulting sample to date. but where still is compared to a timestamp that contains the time, too

the right query for mysql

FROM tablename
date("Y-m-d") does not contain time. If their individual output, then they will be the same: 2018-02-02 - edgardo commented on June 8th 19 at 16:53
Thanks , now understood. - edgardo commented on June 8th 19 at 16:56
health) - maritza_Marquardt commented on June 8th 19 at 16:59
June 8th 19 at 16:52

Find more questions by tags Yii